comma 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Appraisals +6 -1
- data/Gemfile.lock +1 -1
- data/README.markdown +42 -2
- data/gemfiles/{active3.2.11.gemfile → active3.0.20.gemfile} +2 -2
- data/gemfiles/{active3.0.9.gemfile.lock → active3.0.20.gemfile.lock} +17 -17
- data/gemfiles/active3.1.12.gemfile.lock +1 -1
- data/gemfiles/{active3.0.9.gemfile → active3.2.14.gemfile} +2 -2
- data/gemfiles/{active3.2.11.gemfile.lock → active3.2.14.gemfile.lock} +14 -14
- data/gemfiles/active4.0.0.gemfile.lock +1 -1
- data/gemfiles/{rails3.0.9.gemfile → data_mapper1.2.0.gemfile} +2 -2
- data/gemfiles/data_mapper1.2.0.gemfile.lock +101 -0
- data/gemfiles/mongoid3.1.4.gemfile.lock +2 -2
- data/gemfiles/{rails3.1.1.gemfile → rails3.0.20.gemfile} +1 -1
- data/gemfiles/{rails3.0.9.gemfile.lock → rails3.0.20.gemfile.lock} +41 -41
- data/gemfiles/rails3.1.12.gemfile.lock +1 -1
- data/gemfiles/{rails3.2.11.gemfile → rails3.2.14.gemfile} +1 -1
- data/gemfiles/{rails3.2.11.gemfile.lock → rails3.2.14.gemfile.lock} +42 -43
- data/gemfiles/rails4.0.0.gemfile.lock +1 -1
- data/lib/comma.rb +3 -1
- data/lib/comma/data_extractor.rb +78 -0
- data/lib/comma/data_mapper_collection.rb +7 -0
- data/lib/comma/extractor.rb +36 -0
- data/lib/comma/header_extractor.rb +48 -0
- data/lib/comma/object.rb +4 -0
- data/lib/comma/version.rb +1 -1
- data/spec/comma/{extractors_spec.rb → data_extractor_spec.rb} +2 -60
- data/spec/comma/header_extractor_spec.rb +68 -0
- data/spec/comma/rails/data_mapper_collection_spec.rb +49 -0
- metadata +138 -102
- checksums.yaml +0 -15
- data/gemfiles/active3.1.1.gemfile +0 -9
- data/gemfiles/active3.1.1.gemfile.lock +0 -58
- data/gemfiles/rails3.1.1.gemfile.lock +0 -124
- data/lib/comma/extractors.rb +0 -131
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# comma do
|
5
|
+
# name 'Title'
|
6
|
+
# description
|
7
|
+
#
|
8
|
+
# isbn :number_10 => 'ISBN-10', :number_13 => 'ISBN-13'
|
9
|
+
# end
|
10
|
+
|
11
|
+
describe Comma::HeaderExtractor do
|
12
|
+
|
13
|
+
before do
|
14
|
+
@isbn = Isbn.new('123123123', '321321321')
|
15
|
+
@book = Book.new('Smalltalk-80', 'Language and Implementation', @isbn)
|
16
|
+
|
17
|
+
@headers = @book.to_comma_headers
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'when no parameters are provided' do
|
21
|
+
|
22
|
+
it 'should use the method name as the header name, humanized' do
|
23
|
+
@headers.should include('Description')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'when given a string description as a parameter' do
|
28
|
+
|
29
|
+
it 'should use the string value, unmodified' do
|
30
|
+
@headers.should include('Title')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'when an hash is passed as a parameter' do
|
35
|
+
|
36
|
+
describe 'with a string value' do
|
37
|
+
|
38
|
+
it 'should use the string value, unmodified' do
|
39
|
+
@headers.should include('ISBN-10')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'with a non-string value' do
|
44
|
+
|
45
|
+
it 'should use the non string value converted to a string, humanized' do
|
46
|
+
@headers.should include('Issuer')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe Comma::HeaderExtractor, 'with static column method' do
|
55
|
+
before do
|
56
|
+
@headers = Class.new(Struct.new(:id, :name)) do
|
57
|
+
comma do
|
58
|
+
__static_column__
|
59
|
+
__static_column__ 'STATIC'
|
60
|
+
__static_column__ 'STATIC' do '' end
|
61
|
+
end
|
62
|
+
end.new(1, 'John Doe').to_comma_headers
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should extract headers' do
|
66
|
+
@headers.should eq(['', 'STATIC', 'STATIC'])
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
if defined? DataMapper
|
5
|
+
|
6
|
+
describe Comma, 'generating CSV from an DataMapper object' do
|
7
|
+
|
8
|
+
class Person
|
9
|
+
include DataMapper::Resource
|
10
|
+
|
11
|
+
property :id, Serial
|
12
|
+
property :name, String
|
13
|
+
property :age, Integer
|
14
|
+
|
15
|
+
def self.teenagers
|
16
|
+
all(:age.gte => 13) & all(:age.lte => 19)
|
17
|
+
end
|
18
|
+
|
19
|
+
comma do
|
20
|
+
name
|
21
|
+
age
|
22
|
+
end
|
23
|
+
end
|
24
|
+
DataMapper.finalize
|
25
|
+
|
26
|
+
before(:all) do
|
27
|
+
DataMapper.setup(:default, 'sqlite::memory:')
|
28
|
+
DataMapper.auto_migrate!
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:all) do
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "case" do
|
35
|
+
before do
|
36
|
+
@person = Person.new(:age => 18, :name => 'Junior')
|
37
|
+
@person.save
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should extend scope to add a #to_comma method which will return CSV content for objects within the scope' do
|
41
|
+
Person.teenagers.to_comma.should == "Name,Age\nJunior,18\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should find in batches' do
|
45
|
+
Person.teenagers.to_comma
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,129 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: comma
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 3.2.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Marcus Crafter
|
8
14
|
- Tom Meier
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
|
19
|
+
date: 2013-09-16 00:00:00 +10:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
15
23
|
name: activesupport
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - ! '>='
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 3.0.0
|
21
|
-
type: :runtime
|
22
24
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 7
|
31
|
+
segments:
|
32
|
+
- 3
|
33
|
+
- 0
|
34
|
+
- 0
|
27
35
|
version: 3.0.0
|
28
|
-
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
29
39
|
name: rake
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 0.9.2
|
35
|
-
type: :development
|
36
40
|
prerelease: false
|
37
|
-
|
38
|
-
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
39
44
|
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 63
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 9
|
50
|
+
- 2
|
41
51
|
version: 0.9.2
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: sqlite3
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ~>
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 1.3.4
|
49
52
|
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: sqlite3
|
50
56
|
prerelease: false
|
51
|
-
|
52
|
-
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
53
60
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 19
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 3
|
66
|
+
- 4
|
55
67
|
version: 1.3.4
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: appraisal
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.4.1
|
63
68
|
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: appraisal
|
64
72
|
prerelease: false
|
65
|
-
|
66
|
-
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
67
76
|
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 13
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 4
|
82
|
+
- 1
|
69
83
|
version: 0.4.1
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rspec
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 2.8.0
|
77
84
|
type: :development
|
85
|
+
version_requirements: *id004
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: rspec
|
78
88
|
prerelease: false
|
79
|
-
|
80
|
-
|
89
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
81
92
|
- - ~>
|
82
|
-
- !ruby/object:Gem::Version
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 47
|
95
|
+
segments:
|
96
|
+
- 2
|
97
|
+
- 8
|
98
|
+
- 0
|
83
99
|
version: 2.8.0
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: simplecov
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ! '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
100
|
type: :development
|
101
|
+
version_requirements: *id005
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: simplecov
|
92
104
|
prerelease: false
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
105
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id006
|
98
116
|
description: Ruby Comma Seperated Values generation library
|
99
|
-
email:
|
117
|
+
email:
|
100
118
|
- crafterm@redartisan.com
|
101
119
|
- tom@venombytes.com
|
102
120
|
executables: []
|
121
|
+
|
103
122
|
extensions: []
|
123
|
+
|
104
124
|
extra_rdoc_files: []
|
105
|
-
|
125
|
+
|
126
|
+
files:
|
106
127
|
- .gitignore
|
107
128
|
- .travis.yml
|
108
129
|
- Appraisals
|
@@ -112,40 +133,43 @@ files:
|
|
112
133
|
- README.markdown
|
113
134
|
- Rakefile
|
114
135
|
- comma.gemspec
|
115
|
-
- gemfiles/active3.0.
|
116
|
-
- gemfiles/active3.0.
|
117
|
-
- gemfiles/active3.1.1.gemfile
|
118
|
-
- gemfiles/active3.1.1.gemfile.lock
|
136
|
+
- gemfiles/active3.0.20.gemfile
|
137
|
+
- gemfiles/active3.0.20.gemfile.lock
|
119
138
|
- gemfiles/active3.1.12.gemfile
|
120
139
|
- gemfiles/active3.1.12.gemfile.lock
|
121
|
-
- gemfiles/active3.2.
|
122
|
-
- gemfiles/active3.2.
|
140
|
+
- gemfiles/active3.2.14.gemfile
|
141
|
+
- gemfiles/active3.2.14.gemfile.lock
|
123
142
|
- gemfiles/active4.0.0.gemfile
|
124
143
|
- gemfiles/active4.0.0.gemfile.lock
|
144
|
+
- gemfiles/data_mapper1.2.0.gemfile
|
145
|
+
- gemfiles/data_mapper1.2.0.gemfile.lock
|
125
146
|
- gemfiles/mongoid3.1.4.gemfile
|
126
147
|
- gemfiles/mongoid3.1.4.gemfile.lock
|
127
|
-
- gemfiles/rails3.0.
|
128
|
-
- gemfiles/rails3.0.
|
129
|
-
- gemfiles/rails3.1.1.gemfile
|
130
|
-
- gemfiles/rails3.1.1.gemfile.lock
|
148
|
+
- gemfiles/rails3.0.20.gemfile
|
149
|
+
- gemfiles/rails3.0.20.gemfile.lock
|
131
150
|
- gemfiles/rails3.1.12.gemfile
|
132
151
|
- gemfiles/rails3.1.12.gemfile.lock
|
133
|
-
- gemfiles/rails3.2.
|
134
|
-
- gemfiles/rails3.2.
|
152
|
+
- gemfiles/rails3.2.14.gemfile
|
153
|
+
- gemfiles/rails3.2.14.gemfile.lock
|
135
154
|
- gemfiles/rails4.0.0.gemfile
|
136
155
|
- gemfiles/rails4.0.0.gemfile.lock
|
137
156
|
- init.rb
|
138
157
|
- lib/comma.rb
|
139
158
|
- lib/comma/array.rb
|
140
|
-
- lib/comma/
|
159
|
+
- lib/comma/data_extractor.rb
|
160
|
+
- lib/comma/data_mapper_collection.rb
|
161
|
+
- lib/comma/extractor.rb
|
141
162
|
- lib/comma/generator.rb
|
163
|
+
- lib/comma/header_extractor.rb
|
142
164
|
- lib/comma/mongoid.rb
|
143
165
|
- lib/comma/object.rb
|
144
166
|
- lib/comma/relation.rb
|
145
167
|
- lib/comma/version.rb
|
146
168
|
- spec/comma/comma_spec.rb
|
147
|
-
- spec/comma/
|
169
|
+
- spec/comma/data_extractor_spec.rb
|
170
|
+
- spec/comma/header_extractor_spec.rb
|
148
171
|
- spec/comma/rails/active_record_spec.rb
|
172
|
+
- spec/comma/rails/data_mapper_collection_spec.rb
|
149
173
|
- spec/comma/rails/mongoid_spec.rb
|
150
174
|
- spec/controllers/users_controller_spec.rb
|
151
175
|
- spec/non_rails_app/ruby_classes.rb
|
@@ -178,34 +202,46 @@ files:
|
|
178
202
|
- spec/rails_app/script/rails
|
179
203
|
- spec/spec.opts
|
180
204
|
- spec/spec_helper.rb
|
205
|
+
has_rdoc: true
|
181
206
|
homepage: http://github.com/crafterm/comma
|
182
|
-
licenses:
|
207
|
+
licenses:
|
183
208
|
- MIT
|
184
|
-
metadata: {}
|
185
209
|
post_install_message:
|
186
210
|
rdoc_options: []
|
187
|
-
|
211
|
+
|
212
|
+
require_paths:
|
188
213
|
- lib
|
189
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
none: false
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
hash: 3
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
version: "0"
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
|
+
none: false
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
hash: 3
|
229
|
+
segments:
|
230
|
+
- 0
|
231
|
+
version: "0"
|
199
232
|
requirements: []
|
233
|
+
|
200
234
|
rubyforge_project: comma
|
201
|
-
rubygems_version:
|
235
|
+
rubygems_version: 1.6.2
|
202
236
|
signing_key:
|
203
|
-
specification_version:
|
237
|
+
specification_version: 3
|
204
238
|
summary: Ruby Comma Seperated Values generation library
|
205
|
-
test_files:
|
239
|
+
test_files:
|
206
240
|
- spec/comma/comma_spec.rb
|
207
|
-
- spec/comma/
|
241
|
+
- spec/comma/data_extractor_spec.rb
|
242
|
+
- spec/comma/header_extractor_spec.rb
|
208
243
|
- spec/comma/rails/active_record_spec.rb
|
244
|
+
- spec/comma/rails/data_mapper_collection_spec.rb
|
209
245
|
- spec/comma/rails/mongoid_spec.rb
|
210
246
|
- spec/controllers/users_controller_spec.rb
|
211
247
|
- spec/non_rails_app/ruby_classes.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
Y2Q5ZWFkMjgwMjk0OGYzNTg3MTkyMzE0NmZkYmExNjMyN2RhNzYyNw==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmYzZWQyMDhhNmFjNzUzZTVlZDJiMTg3YTk3ODg5MWNjZjZlNWY4Nw==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NTE2ZjcwNjA4YjY2YTIzNjFmNDkzOGRiMDkzMjgwMGM5Y2NiZmFmNTE5ZGI3
|
10
|
-
MjljMTExMDk3OGIyZjk3YzI1NDRlNzVhZGUxZDhjMjJjOWMxMjhiZTRlYzBl
|
11
|
-
ODE4N2ZkY2JhZWQ0YjU1MGQ5ZmIxN2IwYzMwODUwMDliMWUwMTA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZWNmYTk1MDgzODBmMGE4ZDk3NjVlYjFjZDdkZGY3NjQ4NGFjNDVjOWU3Mjg0
|
14
|
-
NzkxNmRkYTU5OTk1ZTk2OTQyZTI4ZTk0YzQ3NmU4OTc4ZGJlN2Y3NTE1M2Iy
|
15
|
-
ZTEzYjQxM2ZlNmMzZmViYTRkZDZkMThmODc2MTM3YjBlOGQ2ZWY=
|