forked from pedjak/grails-csv
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed package name and removed off unused code and added authors de…
…tails.
- Loading branch information
sachin-verma
committed
Jul 9, 2015
1 parent
ed39857
commit 059e5cc
Showing
18 changed files
with
87 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ails/plugins/csv/CsvTestController.groovy → ...ails/plugins/csv/CsvTestController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.grails.plugins.csv | ||
package grails.plugins.csv | ||
|
||
class CsvTestController { | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...org/grails/plugins/csv/Application.groovy → ...nit/grails/plugins/csv/Application.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ls/plugins/csv/CSVMapReaderIntTest.groovy → ...ls/plugins/csv/CSVMapReaderIntTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../plugins/csv/CsvTestControllerSpec.groovy → .../plugins/csv/CsvTestControllerSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...y/org/grails/plugins/csv/CSVWriter.groovy → ...roovy/grails/plugins/csv/CSVWriter.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package org.grails.plugins.csv | ||
package grails.plugins.csv | ||
|
||
import au.com.bytecode.opencsv.CSVReader | ||
import grails.core.GrailsApplication | ||
import grails.plugins.* | ||
import org.grails.plugins.csv.CSVMapReader | ||
import org.grails.plugins.csv.CSVReaderUtils | ||
import org.grails.plugins.csv.controller.RenderCsvMethod | ||
import grails.plugins.csv.controller.RenderCsvMethod | ||
|
||
class GrailsCsvGrailsPlugin extends Plugin { | ||
|
||
|
@@ -16,15 +15,69 @@ class GrailsCsvGrailsPlugin extends Plugin { | |
] | ||
|
||
// TODO Fill in these fields | ||
def title = "Grails Csv" // Headline display name of the plugin | ||
def author = "Your name" | ||
def authorEmail = "" | ||
def description = '''\ | ||
Brief summary/description of the plugin. | ||
''' | ||
def author = "Les Hazlewood" | ||
def authorEmail = "[email protected]" | ||
def title = "Grails CSV Plugin" | ||
def description = ''' | ||
The Grails CSV Plugin allows you to easily parse and consume CSV data from a number of input sources. It | ||
supports complex parsing scenarios such as nested commas inside quotes, escaped tokens, multi-line quoted | ||
values and allows configuration of parsing options (separator char, escape char, text encoding, etc). It is | ||
based on Glen Smith (et. al.)'s OpenCSV project (http://opencsv.sourceforge.net) | ||
This plugin adds two dynamic methods 'eachCsvLine' and 'toCsvReader' to each of the following classes: | ||
- java.lang.String | ||
- java.io.File | ||
- java.io.InputStream | ||
- java.io.Reader | ||
Using it is extremely simple. On any instance of the four data types, call the 'eachCvsLine' method with a | ||
closure accepting the tokens (a String array) for each parsed line: | ||
"hello, world, how, are, you".eachCsvLine { tokens -> | ||
//only one line in this case and tokens.length == 5 | ||
} | ||
new File("iso3166Countries.csv").eachCsvLine { tokens -> | ||
new Country(tokens[0], //ISO 3166 country name | ||
tokens[1]).save() //ISO 3166 2 letter character code | ||
} | ||
Configuration | ||
If you need to specify how the parsing should occur, you can construct your own csv reader with a map of | ||
configuration options and call the 'eachLine' method on the constructed reader: | ||
anInputStream.toCsvReader(['charset':'UTF-8']).eachLine { tokens -> | ||
... | ||
} | ||
The supported config options: | ||
'separatorChar': the character to use as the delimiter to separate the tokens. Defaults to the comma: ',' | ||
'quoteChar': the character indicating a quoted string is about to follow. Internal separatorChars can be | ||
inside the quoted string and they will not be split into tokens. | ||
Defaults to the double quote char: '"' | ||
'escapeChar': the character to escape an immediately following character, indicating to the parser not to treat | ||
it as a special char. Defaults to the backslash char: '\' | ||
'skipLines': the number of lines in the input source to skip before parsing begins. This is useful to skip | ||
any potential CSV header lines that are not part of the CSV data. Defaults to zero '0' | ||
'strictQuotes': if characters outside of quotes should be ignored (implying each individual token is | ||
quoted. Defaults to false | ||
'ignoreLeadingWhiteSpace': white space in front of a quoted token is ignored. Defaults to true | ||
'charset': use the specified charset when parsing an InputStream. The value can be either the Charset name | ||
as a String, a java.nio.charset.Charset instance, or a java.nio.charset.CharsetDecoder instance. | ||
Defaults to the system default charset. | ||
*Note that this option is ONLY valid for InputStream instances. It is ignored otherwise. | ||
''' | ||
// URL to the plugin's documentation | ||
def documentation = "http://grails.org/plugin/grails-csv" | ||
def documentation = "http://grails.org/plugin/csv" | ||
|
||
// Extra (optional) plugin metadata | ||
|
||
|
@@ -35,7 +88,7 @@ Brief summary/description of the plugin. | |
// def organization = [ name: "My Company", url: "http://www.my-company.com/" ] | ||
|
||
// Any additional developers beyond the author specified above. | ||
// def developers = [ [ name: "Joe Bloggs", email: "[email protected]" ]] | ||
def developers = [ [ name: "Sachin Verma", email: "[email protected]"],[ name: "Neha Gupta", email: "[email protected]"] ] | ||
|
||
// Location of the plugin's issue tracker. | ||
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ] | ||
|
@@ -103,15 +156,17 @@ Brief summary/description of the plugin. | |
void onChange(Map<String, Object> event) { | ||
// TODO Implement code that is executed when any artefact that this plugin is | ||
// watching is modified and reloaded. The event contains: event.source, | ||
// event.application, event.manager, event.ctx, and event.plugin. | ||
if (grailsApplication.isControllerClass(event.source)) { | ||
event.source.metaClass.renderCsv = renderCsvMethod | ||
} | ||
} | ||
|
||
void onConfigChange(Map<String, Object> event) { | ||
// TODO Implement code that is executed when the project configuration changes. | ||
// The event is the same as for 'onChange'. | ||
// if (grailsApplication.isControllerClass(event.source)) { | ||
// event.source.metaClass.renderCsv = renderCsvMethod | ||
// } | ||
if (grailsApplication.isControllerClass(event.source)) { | ||
event.source.metaClass.renderCsv = renderCsvMethod | ||
} | ||
} | ||
|
||
void onShutdown(Map<String, Object> event) { | ||
|
4 changes: 2 additions & 2 deletions
4
...ins/csv/controller/RenderCsvMethod.groovy → ...ins/csv/controller/RenderCsvMethod.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../plugins/csv/CSVMapReaderBatchTest.groovy → .../plugins/csv/CSVMapReaderBatchTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.grails.plugins.csv | ||
package grails.plugins.csv | ||
|
||
|
||
class CSVMapReaderBatchTest extends GroovyTestCase { | ||
|
2 changes: 1 addition & 1 deletion
2
...rails/plugins/csv/CSVMapReaderTest.groovy → ...rails/plugins/csv/CSVMapReaderTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.grails.plugins.csv | ||
package grails.plugins.csv | ||
|
||
|
||
class CSVMapReaderTest extends GroovyTestCase { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...g/grails/plugins/csv/CSVWriterTest.groovy → ...y/grails/plugins/csv/CSVWriterTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.grails.plugins.csv | ||
package grails.plugins.csv | ||
|
||
class CSVWriterTest extends GroovyTestCase { | ||
|
||
|