comma 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ree
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - rbx-18mode
8
-
9
- script: "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
3
+ - 'ree'
4
+ - '1.8.7'
5
+ - '1.9.2'
6
+ - '1.9.3'
7
+ - '2.0.0'
8
+ - 'rbx-18mode'
9
+ - 'rbx-19mode'
10
+ before_script: 'rake appraisal:install'
11
+ script: 'rake appraisal spec'
data/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- ['3.0.9', '3.1.1', '~>3.2.8' ].each do |version_number|
1
+ ['3.0.9', '3.1.1', '3.1.12', '3.2.11'].each do |version_number|
2
2
  clean_number = version_number.gsub(/[<>~=]*/, '')
3
3
 
4
4
  appraise "rails#{ clean_number }" do
data/README.markdown CHANGED
@@ -5,12 +5,12 @@ http://github.com/crafterm/comma
5
5
  ##COMPATIBILITY
6
6
  The mainline of this project builds gems to the 3.x version series, and is compatible and tested with :
7
7
 
8
- * Ruby 1.8.7, 1.9.2, 1.9.3
8
+ * Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0
9
9
  * REE 1.8.7
10
10
  * RBX 1.8
11
- * Rails 3.x (all versions)
11
+ * Rails 3.x (all versions, with ActiveRecord and Mongoid support)
12
12
 
13
- [![Build Status](https://secure.travis-ci.org/crafterm/comma.png)](http://travis-ci.org/crafterm/comma)
13
+ [![Build Status](https://travis-ci.org/comma-csv/comma.png?branch=master)](https://travis-ci.org/comma-csv/comma)
14
14
 
15
15
  ###LOOKING FOR RAILS 2?
16
16
  * Rails 2 is supported in the 'rails2' branch of this project, and versioned in the 2.x version of this gem. (https://github.com/crafterm/comma/tree/rails2).
data/comma.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.licenses = ['MIT']
22
+
21
23
  s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
22
24
  s.add_development_dependency('sqlite3', '~> 1.3.4')
23
25
  s.add_development_dependency(%q<appraisal>, ["~> 0.4.1"])
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/development/projects/current/comma
2
+ remote: /Users/tom/src/personal/comma
3
3
  specs:
4
- comma (3.0.3)
4
+ comma (3.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/development/projects/current/comma
2
+ remote: /Users/tom/src/personal/comma
3
3
  specs:
4
- comma (3.0.3)
4
+ comma (3.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "fastercsv", :platforms=>:ruby_18
6
+ gem "activesupport", "3.1.12"
7
+ gem "activerecord", "3.1.12"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: /Users/tom/src/personal/comma
3
+ specs:
4
+ comma (3.0.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activemodel (3.1.12)
10
+ activesupport (= 3.1.12)
11
+ builder (~> 3.0.0)
12
+ i18n (~> 0.6)
13
+ activerecord (3.1.12)
14
+ activemodel (= 3.1.12)
15
+ activesupport (= 3.1.12)
16
+ arel (~> 2.2.3)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.1.12)
19
+ multi_json (~> 1.0)
20
+ appraisal (0.4.1)
21
+ bundler
22
+ rake
23
+ arel (2.2.3)
24
+ builder (3.0.4)
25
+ diff-lcs (1.1.3)
26
+ fastercsv (1.5.5)
27
+ i18n (0.6.4)
28
+ multi_json (1.7.4)
29
+ rake (0.9.6)
30
+ rspec (2.8.0)
31
+ rspec-core (~> 2.8.0)
32
+ rspec-expectations (~> 2.8.0)
33
+ rspec-mocks (~> 2.8.0)
34
+ rspec-core (2.8.0)
35
+ rspec-expectations (2.8.0)
36
+ diff-lcs (~> 1.1.2)
37
+ rspec-mocks (2.8.0)
38
+ simplecov (0.7.1)
39
+ multi_json (~> 1.0)
40
+ simplecov-html (~> 0.7.1)
41
+ simplecov-html (0.7.1)
42
+ sqlite3 (1.3.7)
43
+ tzinfo (0.3.37)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ activerecord (= 3.1.12)
50
+ activesupport (= 3.1.12)
51
+ appraisal (~> 0.4.1)
52
+ comma!
53
+ fastercsv
54
+ rake (~> 0.9.2)
55
+ rspec (~> 2.8.0)
56
+ simplecov
57
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "fastercsv", :platforms=>:ruby_18
6
+ gem "activesupport", "3.2.11"
7
+ gem "activerecord", "3.2.11"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: /Users/tom/src/personal/comma
3
+ specs:
4
+ comma (3.0.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activemodel (3.2.11)
10
+ activesupport (= 3.2.11)
11
+ builder (~> 3.0.0)
12
+ activerecord (3.2.11)
13
+ activemodel (= 3.2.11)
14
+ activesupport (= 3.2.11)
15
+ arel (~> 3.0.2)
16
+ tzinfo (~> 0.3.29)
17
+ activesupport (3.2.11)
18
+ i18n (~> 0.6)
19
+ multi_json (~> 1.0)
20
+ appraisal (0.4.1)
21
+ bundler
22
+ rake
23
+ arel (3.0.2)
24
+ builder (3.0.4)
25
+ diff-lcs (1.1.3)
26
+ fastercsv (1.5.5)
27
+ i18n (0.6.1)
28
+ multi_json (1.5.0)
29
+ rake (0.9.6)
30
+ rspec (2.8.0)
31
+ rspec-core (~> 2.8.0)
32
+ rspec-expectations (~> 2.8.0)
33
+ rspec-mocks (~> 2.8.0)
34
+ rspec-core (2.8.0)
35
+ rspec-expectations (2.8.0)
36
+ diff-lcs (~> 1.1.2)
37
+ rspec-mocks (2.8.0)
38
+ simplecov (0.7.1)
39
+ multi_json (~> 1.0)
40
+ simplecov-html (~> 0.7.1)
41
+ simplecov-html (0.7.1)
42
+ sqlite3 (1.3.7)
43
+ tzinfo (0.3.35)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ activerecord (= 3.2.11)
50
+ activesupport (= 3.2.11)
51
+ appraisal (~> 0.4.1)
52
+ comma!
53
+ fastercsv
54
+ rake (~> 0.9.2)
55
+ rspec (~> 2.8.0)
56
+ simplecov
57
+ sqlite3 (~> 1.3.4)
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/development/projects/current/comma
2
+ remote: /Users/tom/src/personal/comma
3
3
  specs:
4
- comma (3.0.3)
4
+ comma (3.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: /Users/tom/development/projects/current/comma
2
+ remote: /Users/tom/src/personal/comma
3
3
  specs:
4
- comma (3.0.3)
4
+ comma (3.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "fastercsv", :platforms=>:ruby_18
6
+ gem "rails", "3.1.12"
7
+ gem "rspec-rails"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,123 @@
1
+ PATH
2
+ remote: /Users/tom/src/personal/comma
3
+ specs:
4
+ comma (3.0.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.1.12)
10
+ actionpack (= 3.1.12)
11
+ mail (~> 2.4.4)
12
+ actionpack (3.1.12)
13
+ activemodel (= 3.1.12)
14
+ activesupport (= 3.1.12)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ i18n (~> 0.6)
18
+ rack (~> 1.3.6)
19
+ rack-cache (~> 1.2)
20
+ rack-mount (~> 0.8.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.0.4)
23
+ activemodel (3.1.12)
24
+ activesupport (= 3.1.12)
25
+ builder (~> 3.0.0)
26
+ i18n (~> 0.6)
27
+ activerecord (3.1.12)
28
+ activemodel (= 3.1.12)
29
+ activesupport (= 3.1.12)
30
+ arel (~> 2.2.3)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.1.12)
33
+ activemodel (= 3.1.12)
34
+ activesupport (= 3.1.12)
35
+ activesupport (3.1.12)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.4.1)
38
+ bundler
39
+ rake
40
+ arel (2.2.3)
41
+ builder (3.0.4)
42
+ diff-lcs (1.1.3)
43
+ erubis (2.7.0)
44
+ fastercsv (1.5.5)
45
+ hike (1.2.2)
46
+ i18n (0.6.4)
47
+ json (1.8.0)
48
+ mail (2.4.4)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.23)
53
+ multi_json (1.7.4)
54
+ polyglot (0.3.3)
55
+ rack (1.3.10)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-mount (0.8.3)
59
+ rack (>= 1.0.0)
60
+ rack-ssl (1.3.3)
61
+ rack
62
+ rack-test (0.6.2)
63
+ rack (>= 1.0)
64
+ rails (3.1.12)
65
+ actionmailer (= 3.1.12)
66
+ actionpack (= 3.1.12)
67
+ activerecord (= 3.1.12)
68
+ activeresource (= 3.1.12)
69
+ activesupport (= 3.1.12)
70
+ bundler (~> 1.0)
71
+ railties (= 3.1.12)
72
+ railties (3.1.12)
73
+ actionpack (= 3.1.12)
74
+ activesupport (= 3.1.12)
75
+ rack-ssl (~> 1.3.2)
76
+ rake (>= 0.8.7)
77
+ rdoc (~> 3.4)
78
+ thor (~> 0.14.6)
79
+ rake (0.9.6)
80
+ rdoc (3.12.2)
81
+ json (~> 1.4)
82
+ rspec (2.8.0)
83
+ rspec-core (~> 2.8.0)
84
+ rspec-expectations (~> 2.8.0)
85
+ rspec-mocks (~> 2.8.0)
86
+ rspec-core (2.8.0)
87
+ rspec-expectations (2.8.0)
88
+ diff-lcs (~> 1.1.2)
89
+ rspec-mocks (2.8.0)
90
+ rspec-rails (2.8.1)
91
+ actionpack (>= 3.0)
92
+ activesupport (>= 3.0)
93
+ railties (>= 3.0)
94
+ rspec (~> 2.8.0)
95
+ simplecov (0.7.1)
96
+ multi_json (~> 1.0)
97
+ simplecov-html (~> 0.7.1)
98
+ simplecov-html (0.7.1)
99
+ sprockets (2.0.4)
100
+ hike (~> 1.2)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ sqlite3 (1.3.7)
104
+ thor (0.14.6)
105
+ tilt (1.4.1)
106
+ treetop (1.4.12)
107
+ polyglot
108
+ polyglot (>= 0.3.1)
109
+ tzinfo (0.3.37)
110
+
111
+ PLATFORMS
112
+ ruby
113
+
114
+ DEPENDENCIES
115
+ appraisal (~> 0.4.1)
116
+ comma!
117
+ fastercsv
118
+ rails (= 3.1.12)
119
+ rake (~> 0.9.2)
120
+ rspec (~> 2.8.0)
121
+ rspec-rails
122
+ simplecov
123
+ sqlite3 (~> 1.3.4)
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "fastercsv", :platforms=>:ruby_18
6
+ gem "rails", "3.2.11"
7
+ gem "rspec-rails"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: /Users/tom/src/personal/comma
3
+ specs:
4
+ comma (3.0.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.11)
10
+ actionpack (= 3.2.11)
11
+ mail (~> 2.4.4)
12
+ actionpack (3.2.11)
13
+ activemodel (= 3.2.11)
14
+ activesupport (= 3.2.11)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activemodel (3.2.11)
23
+ activesupport (= 3.2.11)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.11)
26
+ activemodel (= 3.2.11)
27
+ activesupport (= 3.2.11)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.11)
31
+ activemodel (= 3.2.11)
32
+ activesupport (= 3.2.11)
33
+ activesupport (3.2.11)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ appraisal (0.4.1)
37
+ bundler
38
+ rake
39
+ arel (3.0.2)
40
+ builder (3.0.4)
41
+ diff-lcs (1.1.3)
42
+ erubis (2.7.0)
43
+ fastercsv (1.5.5)
44
+ hike (1.2.1)
45
+ i18n (0.6.1)
46
+ journey (1.0.4)
47
+ json (1.7.6)
48
+ mail (2.4.4)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.20.1)
53
+ multi_json (1.5.0)
54
+ polyglot (0.3.3)
55
+ rack (1.4.4)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.3)
59
+ rack
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (3.2.11)
63
+ actionmailer (= 3.2.11)
64
+ actionpack (= 3.2.11)
65
+ activerecord (= 3.2.11)
66
+ activeresource (= 3.2.11)
67
+ activesupport (= 3.2.11)
68
+ bundler (~> 1.0)
69
+ railties (= 3.2.11)
70
+ railties (3.2.11)
71
+ actionpack (= 3.2.11)
72
+ activesupport (= 3.2.11)
73
+ rack-ssl (~> 1.3.2)
74
+ rake (>= 0.8.7)
75
+ rdoc (~> 3.4)
76
+ thor (>= 0.14.6, < 2.0)
77
+ rake (0.9.6)
78
+ rdoc (3.12)
79
+ json (~> 1.4)
80
+ rspec (2.8.0)
81
+ rspec-core (~> 2.8.0)
82
+ rspec-expectations (~> 2.8.0)
83
+ rspec-mocks (~> 2.8.0)
84
+ rspec-core (2.8.0)
85
+ rspec-expectations (2.8.0)
86
+ diff-lcs (~> 1.1.2)
87
+ rspec-mocks (2.8.0)
88
+ rspec-rails (2.8.1)
89
+ actionpack (>= 3.0)
90
+ activesupport (>= 3.0)
91
+ railties (>= 3.0)
92
+ rspec (~> 2.8.0)
93
+ simplecov (0.7.1)
94
+ multi_json (~> 1.0)
95
+ simplecov-html (~> 0.7.1)
96
+ simplecov-html (0.7.1)
97
+ sprockets (2.2.2)
98
+ hike (~> 1.2)
99
+ multi_json (~> 1.0)
100
+ rack (~> 1.0)
101
+ tilt (~> 1.1, != 1.3.0)
102
+ sqlite3 (1.3.7)
103
+ thor (0.17.0)
104
+ tilt (1.3.3)
105
+ treetop (1.4.12)
106
+ polyglot
107
+ polyglot (>= 0.3.1)
108
+ tzinfo (0.3.35)
109
+
110
+ PLATFORMS
111
+ ruby
112
+
113
+ DEPENDENCIES
114
+ appraisal (~> 0.4.1)
115
+ comma!
116
+ fastercsv
117
+ rails (= 3.2.11)
118
+ rake (~> 0.9.2)
119
+ rspec (~> 2.8.0)
120
+ rspec-rails
121
+ simplecov
122
+ sqlite3 (~> 1.3.4)
data/lib/comma.rb CHANGED
@@ -27,6 +27,7 @@ end
27
27
  require 'active_support/core_ext/class/attribute'
28
28
  require 'active_support/core_ext/module/delegation'
29
29
  require 'comma/relation' if defined?(ActiveRecord::Relation)
30
+ require 'comma/mongoid'
30
31
 
31
32
  require 'comma/extractors'
32
33
  require 'comma/generator'
@@ -10,16 +10,23 @@ module Comma
10
10
 
11
11
  def results
12
12
  instance_eval &@block
13
- @results
13
+ @results.map { |r| convert_to_data_value(r) }
14
14
  end
15
15
 
16
- def id(*args)
17
- method_missing(:id, *args)
16
+ def id(*args, &block)
17
+ method_missing(:id, *args, &block)
18
18
  end
19
+
20
+ private
21
+
22
+ def convert_to_data_value(result)
23
+ result.nil? ? result : result.to_s
24
+ end
25
+
19
26
  end
20
27
 
21
28
  class HeaderExtractor < Extractor
22
-
29
+
23
30
  def method_missing(sym, *args, &block)
24
31
  @results << sym.to_s.humanize if args.blank?
25
32
  args.each do |arg|
@@ -37,38 +44,65 @@ module Comma
37
44
  end
38
45
  end
39
46
  end
47
+
48
+ def __static_column__(header = '', &block)
49
+ @results << header
50
+ end
40
51
  end
41
52
 
42
53
  class DataExtractor < Extractor
43
54
 
44
55
  def method_missing(sym, *args, &block)
45
56
  if args.blank?
46
- result = block ? yield(@instance.send(sym)) : @instance.send(sym)
47
- @results << result.to_s
57
+ @results << yield_block_with_value(
58
+ extract_value_from_object(@instance, sym), &block)
48
59
  end
49
60
 
50
61
  args.each do |arg|
51
62
  case arg
52
63
  when Hash
53
64
  arg.each do |k, v|
54
- if block
55
- @results << (@instance.send(sym).nil? ? '' : yield(@instance.send(sym).send(k)).to_s )
56
- else
57
- @results << (@instance.send(sym).nil? ? '' : @instance.send(sym).send(k).to_s )
58
- end
65
+ @results << yield_block_with_value(
66
+ extract_value_from_object(
67
+ get_association(@instance, sym), k), &block)
59
68
  end
60
69
  when Symbol
61
- if block
62
- @results << (@instance.send(sym).nil? ? '' : yield(@instance.send(sym).send(arg)).to_s)
63
- else
64
- @results << ( @instance.send(sym).nil? ? '' : @instance.send(sym).send(arg).to_s )
65
- end
70
+ @results << yield_block_with_value(
71
+ extract_value_from_object(
72
+ get_association(@instance, sym), arg), &block)
66
73
  when String
67
- @results << (block ? yield(@instance.send(sym)) : @instance.send(sym)).to_s
74
+ @results << yield_block_with_value(
75
+ extract_value_from_object(@instance, sym), &block)
68
76
  else
69
77
  raise "Unknown data symbol #{arg.inspect}"
70
78
  end
71
79
  end
72
80
  end
81
+
82
+ def __static_column__(header = nil, &block)
83
+ @results << (block ? yield : nil)
84
+ end
85
+
86
+ private
87
+
88
+ def yield_block_with_value(value, &block)
89
+ block ? yield(value) : value
90
+ end
91
+
92
+ def extract_value_from_object(object, method)
93
+ object.send(method)
94
+ end
95
+
96
+ def get_association(model, association_name)
97
+ model.send(association_name) || NullAssociation.new
98
+ end
99
+
73
100
  end
101
+
102
+ class NullAssociation < Class.const_defined?(:BasicObject) ? ::BasicObject : ::Object
103
+ def method_missing(symbol, *args, &block)
104
+ nil
105
+ end
106
+ end
107
+
74
108
  end
@@ -0,0 +1,12 @@
1
+ #Conditionally set to_comma on Mongoid records if mongoid gem is installed
2
+ begin
3
+ require 'mongoid'
4
+ class Mongoid::Criteria
5
+ def to_comma(style = :default)
6
+ Comma::Generator.new(self, style).run(:each)
7
+ end
8
+ end
9
+ rescue LoadError
10
+ end
11
+
12
+
data/lib/comma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Comma
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
@@ -50,6 +50,22 @@ describe Comma::HeaderExtractor do
50
50
 
51
51
  end
52
52
 
53
+ describe Comma::HeaderExtractor, 'with static column method' do
54
+ before do
55
+ @headers = Class.new(Struct.new(:id, :name)) do
56
+ comma do
57
+ __static_column__
58
+ __static_column__ 'STATIC'
59
+ __static_column__ 'STATIC' do '' end
60
+ end
61
+ end.new(1, 'John Doe').to_comma_headers
62
+ end
63
+
64
+ it 'should extract headers' do
65
+ @headers.should eq(['', 'STATIC', 'STATIC'])
66
+ end
67
+ end
68
+
53
69
  describe Comma::DataExtractor do
54
70
 
55
71
  before do
@@ -89,3 +105,49 @@ describe Comma::DataExtractor do
89
105
  end
90
106
 
91
107
  end
108
+
109
+ describe Comma::DataExtractor, 'id attribute' do
110
+ before do
111
+ @data = Class.new(Struct.new(:id)) do
112
+ comma do
113
+ id 'ID' do |id| '42' end
114
+ end
115
+ end.new(1).to_comma
116
+ end
117
+
118
+ it 'id attribute should yield block' do
119
+ @data.should include('42')
120
+ end
121
+ end
122
+
123
+ describe Comma::DataExtractor, 'with static column method' do
124
+ before do
125
+ @data = Class.new(Struct.new(:id, :name)) do
126
+ comma do
127
+ __static_column__
128
+ __static_column__ 'STATIC'
129
+ __static_column__ 'STATIC' do '' end
130
+ end
131
+ end.new(1, 'John Doe').to_comma
132
+ end
133
+
134
+ it 'should extract headers' do
135
+ @data.should eq([nil, nil, ''])
136
+ end
137
+ end
138
+
139
+ describe Comma::DataExtractor, 'nil value' do
140
+ before do
141
+ @data = Class.new(Struct.new(:id, :name)) do
142
+ comma do
143
+ name
144
+ name 'Name'
145
+ name 'Name' do |name| nil end
146
+ end
147
+ end.new(1, nil).to_comma
148
+ end
149
+
150
+ it 'should extract nil' do
151
+ @data.should eq([nil, nil, nil])
152
+ end
153
+ end
metadata CHANGED
@@ -1,107 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: comma
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 3
8
+ - 0
9
+ - 5
10
+ version: 3.0.5
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Marcus Crafter
9
14
  - Tom Meier
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-11-11 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2013-08-13 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: rake
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 0.9.2
23
- type: :development
24
23
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
- requirements:
26
+ requirements:
28
27
  - - ~>
29
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 63
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 2
30
34
  version: 0.9.2
31
- - !ruby/object:Gem::Dependency
32
- name: sqlite3
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: 1.3.4
39
35
  type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: sqlite3
40
39
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
42
41
  none: false
43
- requirements:
42
+ requirements:
44
43
  - - ~>
45
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 1
48
+ - 3
49
+ - 4
46
50
  version: 1.3.4
47
- - !ruby/object:Gem::Dependency
48
- name: appraisal
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.4.1
55
51
  type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: appraisal
56
55
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
56
+ requirement: &id003 !ruby/object:Gem::Requirement
58
57
  none: false
59
- requirements:
58
+ requirements:
60
59
  - - ~>
61
- - !ruby/object:Gem::Version
60
+ - !ruby/object:Gem::Version
61
+ hash: 13
62
+ segments:
63
+ - 0
64
+ - 4
65
+ - 1
62
66
  version: 0.4.1
63
- - !ruby/object:Gem::Dependency
64
- name: rspec
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: 2.8.0
71
67
  type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
72
71
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
74
73
  none: false
75
- requirements:
74
+ requirements:
76
75
  - - ~>
77
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
77
+ hash: 47
78
+ segments:
79
+ - 2
80
+ - 8
81
+ - 0
78
82
  version: 2.8.0
79
- - !ruby/object:Gem::Dependency
80
- name: simplecov
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ! '>='
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
83
  type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: simplecov
88
87
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
90
89
  none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ type: :development
98
+ version_requirements: *id005
95
99
  description: Ruby Comma Seperated Values generation library
96
- email:
100
+ email:
97
101
  - crafterm@redartisan.com
98
102
  - tom@venombytes.com
99
103
  executables: []
104
+
100
105
  extensions: []
106
+
101
107
  extra_rdoc_files: []
102
- files:
108
+
109
+ files:
103
110
  - .gitignore
104
- - .rvmrc
105
111
  - .travis.yml
106
112
  - Appraisals
107
113
  - Gemfile
@@ -114,14 +120,22 @@ files:
114
120
  - gemfiles/active3.0.9.gemfile.lock
115
121
  - gemfiles/active3.1.1.gemfile
116
122
  - gemfiles/active3.1.1.gemfile.lock
123
+ - gemfiles/active3.1.12.gemfile
124
+ - gemfiles/active3.1.12.gemfile.lock
117
125
  - gemfiles/active3.2.1.gemfile
118
126
  - gemfiles/active3.2.1.gemfile.lock
127
+ - gemfiles/active3.2.11.gemfile
128
+ - gemfiles/active3.2.11.gemfile.lock
119
129
  - gemfiles/active3.2.8.gemfile
120
130
  - gemfiles/active3.2.8.gemfile.lock
121
131
  - gemfiles/rails3.0.9.gemfile
122
132
  - gemfiles/rails3.0.9.gemfile.lock
123
133
  - gemfiles/rails3.1.1.gemfile
124
134
  - gemfiles/rails3.1.1.gemfile.lock
135
+ - gemfiles/rails3.1.12.gemfile
136
+ - gemfiles/rails3.1.12.gemfile.lock
137
+ - gemfiles/rails3.2.11.gemfile
138
+ - gemfiles/rails3.2.11.gemfile.lock
125
139
  - gemfiles/rails3.2.8.gemfile
126
140
  - gemfiles/rails3.2.8.gemfile.lock
127
141
  - init.rb
@@ -129,6 +143,7 @@ files:
129
143
  - lib/comma/array.rb
130
144
  - lib/comma/extractors.rb
131
145
  - lib/comma/generator.rb
146
+ - lib/comma/mongoid.rb
132
147
  - lib/comma/object.rb
133
148
  - lib/comma/relation.rb
134
149
  - lib/comma/version.rb
@@ -167,36 +182,39 @@ files:
167
182
  - spec/spec.opts
168
183
  - spec/spec_helper.rb
169
184
  homepage: http://github.com/crafterm/comma
170
- licenses: []
185
+ licenses:
186
+ - MIT
171
187
  post_install_message:
172
188
  rdoc_options: []
173
- require_paths:
189
+
190
+ require_paths:
174
191
  - lib
175
- required_ruby_version: !ruby/object:Gem::Requirement
192
+ required_ruby_version: !ruby/object:Gem::Requirement
176
193
  none: false
177
- requirements:
178
- - - ! '>='
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- segments:
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ hash: 3
198
+ segments:
182
199
  - 0
183
- hash: -692163950360334906
184
- required_rubygems_version: !ruby/object:Gem::Requirement
200
+ version: "0"
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
202
  none: false
186
- requirements:
187
- - - ! '>='
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
- segments:
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
191
208
  - 0
192
- hash: -692163950360334906
209
+ version: "0"
193
210
  requirements: []
211
+
194
212
  rubyforge_project: comma
195
- rubygems_version: 1.8.23
213
+ rubygems_version: 1.8.24
196
214
  signing_key:
197
215
  specification_version: 3
198
216
  summary: Ruby Comma Seperated Values generation library
199
- test_files:
217
+ test_files:
200
218
  - spec/comma/comma_spec.rb
201
219
  - spec/comma/extractors_spec.rb
202
220
  - spec/comma/rails/active_record_spec.rb
@@ -231,3 +249,4 @@ test_files:
231
249
  - spec/rails_app/script/rails
232
250
  - spec/spec.opts
233
251
  - spec/spec_helper.rb
252
+ has_rdoc:
data/.rvmrc DELETED
@@ -1,5 +0,0 @@
1
- rvm 1.9.2-p290@comma --create
2
-
3
- if ! command -v bundle ; then
4
- gem install bundler
5
- fi