rightcsv 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +10 -10
  3. data/lib/rightcsv.rb +5 -5
  4. data/rightcsv.gemspec +3 -1
  5. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b41c1fbcdd5e71a24c209d9e45144cb0c48c8f45
4
- data.tar.gz: bb22f72c493e94f0c291a9c055c255a89c42836c
2
+ SHA256:
3
+ metadata.gz: 4070765799c0e9ac42f5fbabbd4b50267e26714666e24d35a97244daad0f7e30
4
+ data.tar.gz: 7ae613f9a62ea72299d8eee9690ecbb46fd37fb135da5f7547f88041f41a912e
5
5
  SHA512:
6
- metadata.gz: 39f47e4a6d322c7e0489815ecbf3fb857e9f5c8d353fcbaed6612cb19fc0252eea9590ba75d289664af8943beee60a366622d6e962444206350a53fc36f103e4
7
- data.tar.gz: 249e41c03316b25b662efd0fae3606d5d5a3fbb29b403b650948016d42cb98133f03167dfe8d934299649c551ae7b8ab9c08350b7b9caec0d0289aa045afdcef
6
+ metadata.gz: a1074b486da35cb4197273e65d1722ff9070d53ca76d3084606d39aacce4f4db21e8792c0813c8d4fcd19ffc47d0f89139a26d30ae696ebd8cb4fd360c79bcc8
7
+ data.tar.gz: 1e246e7fffdd659050915bbfa5dd3e4f31faf2dbc697136e4cd74509500db8c249ee13b92ac72580a760f1b9e32f6138e86012616f0cda5d22ac8e2ca9acadf1
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Rightcsv
1
+ # RightCSV
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rightcsv`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ The CSV library that returns empty string instead of nil.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,14 +20,16 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
23
+ ```ruby
24
+ require 'rightcsv'
28
25
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+ CSV.parse('a,,"","1,2"') #=> [["a", nil, "", "1,2"]]
27
+ RightCSV.parse('a,,"","1,2"') #=> [["a", "", "", "1,2"]]
30
28
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+ CSV.generate_line(['a', nil, '', '1,2']) #=> "a,,\"\",\"1,2\"\n"
30
+ RightCSV.generate_line(['a', nil, '', '1,2']) #=> "a,,,\"1,2\"\n"
31
+ ```
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rightcsv.
35
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/tmtm/rightcsv>.
data/lib/rightcsv.rb CHANGED
@@ -11,7 +11,11 @@
11
11
  require 'csv'
12
12
 
13
13
  class RightCSV < CSV
14
- def init_separators(options)
14
+ def initialize(data, **options)
15
+ super(data, options.merge(nil_value: ''))
16
+ end
17
+
18
+ def init_separators(*)
15
19
  super
16
20
  unless @force_quotes
17
21
  quote_orig = @quote
@@ -20,10 +24,6 @@ class RightCSV < CSV
20
24
  end
21
25
  end
22
26
  end
23
-
24
- def shift
25
- super&.map{ |s| s.nil? ? '' : s }
26
- end
27
27
  end
28
28
 
29
29
  class Array
data/rightcsv.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rightcsv"
7
- spec.version = '0.1.0'
7
+ spec.version = '0.2.0'
8
8
  spec.licenses = ['MIT']
9
9
  spec.authors = ["TOMITA Masahiro"]
10
10
  spec.email = ["tommy@tmtm.org"]
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
+ spec.add_dependency 'csv', '~> 1.0.2'
24
+
23
25
  spec.add_development_dependency "bundler", "~> 1.15"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
25
27
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rightcsv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOMITA Masahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-18 00:00:00.000000000 Z
11
+ date: 2018-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: csv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
102
  version: '0'
89
103
  requirements: []
90
104
  rubyforge_project:
91
- rubygems_version: 2.6.8
105
+ rubygems_version: 2.7.4
92
106
  signing_key:
93
107
  specification_version: 4
94
108
  summary: right CSV library