enum_csv 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5adcc47fbd7b34a09baac9c8ac6c54f86c316ba1
4
- data.tar.gz: 47d03538cf37af19be66993d618526b6bc03dddb
3
+ metadata.gz: 9ca3cb725d6f4a47be3ac7145ee80bdbe420c1d4
4
+ data.tar.gz: b28cc4f0c6c523df4c71d2237ea668c183729f73
5
5
  SHA512:
6
- metadata.gz: 532750b7c690dd1960462a18ddb610915cc70effa99c46719e1ffc4108503b3715e9f4ec26f62ff591765bda336a7f22add9438e6f43ef367659cf9319aadacd
7
- data.tar.gz: e72e5b42e72913a3840f297f4a6684f26424e77aaff93136bc2174aaf37d3a110e8d87066130e410cd47e131f8fc23a1ba6b5a81b76b892d2be7774f77fa3bee
6
+ metadata.gz: 3f56f71c6eadcb3278d353b092d504a60b7bb83dce0a123598ca3559e22927c4e48d4ceb56acf12488a7916fc0b8713a6bed2f03357d877ad61554e3b832aa45
7
+ data.tar.gz: 31e4c7948415934ed139d0bf655948900be85baf6fb2eabb49495cfc7fb301e502807d22e214132b01ab876d2fc524abfd00f3a714752682a753f948ef41de46
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.1.0 (2015-01-27)
2
+
3
+ * Support a comma-delimited string for the :headers option (jeremyevans)
4
+
5
+ * Fix homepage in gemspec (jeremyevans)
6
+
1
7
  === 1.0.0 (2013-12-18)
2
8
 
3
9
  * Initial Public Release
@@ -22,6 +22,7 @@ arrays), and returns a string containing the CSV output:
22
22
  You can use the :headers option to set custom headers:
23
23
 
24
24
  EnumCSV.csv([[1, 2], [3,"4,5"]], :headers=>['A', 'B']) => "A,B\n1,2\n3,\"4,5\"\n"
25
+ EnumCSV.csv([[1, 2], [3,"4,5"]], :headers=>'A,B') => "A,B\n1,2\n3,\"4,5\"\n"
25
26
 
26
27
  The :file option can be used to output to a file:
27
28
 
@@ -31,7 +32,7 @@ If a block is passed to the method, all items in the enumerable are yielded to
31
32
  the block, and the block should return an array with the data to use in the CSV
32
33
  output:
33
34
 
34
- EnumCSV.csv([{:a=>1, :b=>2}, {:a=>3, b=>4}]){|line| [l[:b], l[:a] + 10]} => "2,11\n4,13\n"
35
+ EnumCSV.csv([{:a=>1, :b=>2}, {:a=>3, :b=>4}]){|l| [l[:b], l[:a] + 10]} => "2,11\n4,13\n"
35
36
 
36
37
  = Ruby 1.8 Usage
37
38
 
data/Rakefile CHANGED
@@ -36,7 +36,7 @@ begin
36
36
  spec.call("spec", Dir["spec/*_spec.rb"], "Run specs")
37
37
  rescue LoadError
38
38
  task :default do
39
- puts "Must install rspec >=2.0 to run the default task (which runs specs)"
39
+ puts "Must install rspec to run the default task (which runs specs)"
40
40
  end
41
41
  end
42
42
 
@@ -15,13 +15,16 @@ module EnumCSV
15
15
  #
16
16
  # Options:
17
17
  # :headers :: Should be an array of headers to use as the first
18
- # line of the CSV output.
18
+ # line of the CSV output, or a comma-delimited string
19
+ # of headers.
19
20
  # :file :: Output to the given file and return nil instead of
20
21
  # returning a string with the CSV output.
21
22
  # all other options :: Passed to CSV.open or CSV.generate
22
23
  def csv(enum, opts={})
23
- if opts[:headers].is_a?(Array) && !opts.has_key?(:write_headers)
24
- opts = opts.merge(:write_headers=>true)
24
+ headers = opts[:headers]
25
+ headers = headers.split(',') if headers.is_a?(String)
26
+ if headers.is_a?(Array) && !opts.has_key?(:write_headers)
27
+ opts = opts.merge(:write_headers=>true, :headers=>headers)
25
28
  end
26
29
 
27
30
  csv_proc = proc do |csv|
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require File.join(File.dirname(File.expand_path(__FILE__)), '../lib/enum_csv')
2
3
 
3
4
  describe "EnumCSV.csv" do
@@ -20,6 +21,11 @@ describe "EnumCSV.csv" do
20
21
  EnumCSV.csv([[1, nil], [3, 4]], :headers=>['a', nil]).should == "a,\n1,\n3,4\n"
21
22
  end
22
23
 
24
+ it "should support :headers option as a comma delimited string" do
25
+ EnumCSV.csv([[1, 2]], :headers=>'a,b').should == "a,b\n1,2\n"
26
+ EnumCSV.csv([[1, 2], [3, 4]], :headers=>'a,b').should == "a,b\n1,2\n3,4\n"
27
+ end
28
+
23
29
  it "should support :file option for writing to a file" do
24
30
  EnumCSV.csv([[1, 2]], :file=>TEST_FILE).should be_nil
25
31
  File.read(TEST_FILE).should == "1,2\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enum_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  EnumCSV exposes a single method, csv, for easily creating CSV
@@ -21,40 +21,40 @@ extra_rdoc_files:
21
21
  - CHANGELOG
22
22
  - MIT-LICENSE
23
23
  files:
24
- - MIT-LICENSE
25
24
  - CHANGELOG
25
+ - MIT-LICENSE
26
26
  - README.rdoc
27
27
  - Rakefile
28
- - spec/enum_csv_spec.rb
29
28
  - lib/enum_csv.rb
30
- homepage: http://gihub.com/jeremyevans/enum_csv
29
+ - spec/enum_csv_spec.rb
30
+ homepage: http://github.com/jeremyevans/enum_csv
31
31
  licenses:
32
32
  - MIT
33
33
  metadata: {}
34
34
  post_install_message:
35
35
  rdoc_options:
36
- - --quiet
37
- - --line-numbers
38
- - --inline-source
39
- - --title
36
+ - "--quiet"
37
+ - "--line-numbers"
38
+ - "--inline-source"
39
+ - "--title"
40
40
  - 'EnumCSV: Create CSV from Enumerables'
41
- - --main
41
+ - "--main"
42
42
  - README.rdoc
43
43
  require_paths:
44
44
  - lib
45
45
  required_ruby_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 2.0.14
57
+ rubygems_version: 2.4.5
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: Create CSV from Enumerables