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
data/Appraisals
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
['3.0.
|
1
|
+
['3.0.20', '3.1.12', '3.2.14', '4.0.0'].each do |version_number|
|
2
2
|
clean_number = version_number.gsub(/[<>~=]*/, '')
|
3
3
|
next if RUBY_VERSION < '1.9.3' && version_number >= '4.0.0'
|
4
4
|
|
@@ -18,3 +18,8 @@ if RUBY_VERSION >= '1.9.3'
|
|
18
18
|
gem 'mongoid', '3.1.4'
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
appraise 'data_mapper1.2.0' do
|
23
|
+
gem 'data_mapper', '1.2.0'
|
24
|
+
gem 'dm-sqlite-adapter', '1.2.0'
|
25
|
+
end
|
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -10,7 +10,7 @@ The mainline of this project builds gems to the 3.x version series, and is compa
|
|
10
10
|
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0
|
11
11
|
* REE 1.8.7
|
12
12
|
* RBX 1.8 mode, 1.9 mode
|
13
|
-
* Rails 3.x (all versions, with ActiveRecord and Mongoid support)
|
13
|
+
* Rails 3.x (all versions, with ActiveRecord, DataMapper and Mongoid support)
|
14
14
|
|
15
15
|
[![Build Status](https://travis-ci.org/comma-csv/comma.png?branch=master)](https://travis-ci.org/comma-csv/comma) [![Code Climate](https://codeclimate.com/github/comma-csv/comma.png)](https://codeclimate.com/github/comma-csv/comma)
|
16
16
|
|
@@ -227,6 +227,47 @@ In the preceding example, the 2 new fields added (both based on the publisher re
|
|
227
227
|
* the first example 'publishers_contact' is loaded straight as a block. The value returned by the lambda is displayed with a header value of 'Publisher'
|
228
228
|
* the second example 'total_publishers_users' is sent via a hash and a custom label is set, if used in the first examples method the header would be 'Publisher', but sent as a hash the header is 'Number of publisher users'.
|
229
229
|
|
230
|
+
##Using special fields
|
231
|
+
|
232
|
+
###\_\_use\_\_
|
233
|
+
|
234
|
+
With `__use__` field, you can reuse output formats that are defined in
|
235
|
+
the same class. In the example below, default format (`:default`)
|
236
|
+
includes `:minimum` format when `#to_comma` is called.
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
class Book < ActiveRecord::Base
|
240
|
+
comma do
|
241
|
+
__use__ :minimum
|
242
|
+
|
243
|
+
description
|
244
|
+
|
245
|
+
isbn :number_10 => 'ISBN-10', :number_13 => 'ISBN-13'
|
246
|
+
end
|
247
|
+
|
248
|
+
comma :minimum do
|
249
|
+
name
|
250
|
+
end
|
251
|
+
end
|
252
|
+
```
|
253
|
+
|
254
|
+
###\_\_static_column\_\_
|
255
|
+
|
256
|
+
When you want to have static value in your CSV output, you can use
|
257
|
+
`__static__` field. You can provide values to output to blocks.
|
258
|
+
Without block, field will become empty.
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
class Book < ActiveRecord::Base
|
262
|
+
comma do
|
263
|
+
__static_column__ 'Check' do ' ' end
|
264
|
+
name
|
265
|
+
__static_column__ 'Spacer'
|
266
|
+
description
|
267
|
+
end
|
268
|
+
end
|
269
|
+
```
|
270
|
+
|
230
271
|
##USING WITH RAILS
|
231
272
|
|
232
273
|
When used with Rails (ie. add 'comma' as a gem dependency), Comma automatically adds support for rendering CSV output in your controllers:
|
@@ -323,4 +364,3 @@ When rebuilding for a new rails version, to test across controller and the stack
|
|
323
364
|
```
|
324
365
|
rails plugin new rails_app --full --dummy-path=spec/dummy --skip-bundle --skip-gemspec --skip-test-unit --skip-sprockets --skip-javascript --skip-gemfile --skip-git
|
325
366
|
```
|
326
|
-
|
@@ -1,32 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
comma (3.
|
4
|
+
comma (3.2.0)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.0.
|
11
|
-
activesupport (= 3.0.
|
10
|
+
activemodel (3.0.20)
|
11
|
+
activesupport (= 3.0.20)
|
12
12
|
builder (~> 2.1.2)
|
13
13
|
i18n (~> 0.5.0)
|
14
|
-
activerecord (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
14
|
+
activerecord (3.0.20)
|
15
|
+
activemodel (= 3.0.20)
|
16
|
+
activesupport (= 3.0.20)
|
17
17
|
arel (~> 2.0.10)
|
18
18
|
tzinfo (~> 0.3.23)
|
19
|
-
activesupport (3.0.
|
19
|
+
activesupport (3.0.20)
|
20
20
|
appraisal (0.4.1)
|
21
21
|
bundler
|
22
22
|
rake
|
23
23
|
arel (2.0.10)
|
24
24
|
builder (2.1.2)
|
25
25
|
diff-lcs (1.1.3)
|
26
|
-
fastercsv (1.5.
|
26
|
+
fastercsv (1.5.5)
|
27
27
|
i18n (0.5.0)
|
28
|
-
multi_json (1.
|
29
|
-
rake (0.9.
|
28
|
+
multi_json (1.7.9)
|
29
|
+
rake (0.9.6)
|
30
30
|
rspec (2.8.0)
|
31
31
|
rspec-core (~> 2.8.0)
|
32
32
|
rspec-expectations (~> 2.8.0)
|
@@ -35,19 +35,19 @@ GEM
|
|
35
35
|
rspec-expectations (2.8.0)
|
36
36
|
diff-lcs (~> 1.1.2)
|
37
37
|
rspec-mocks (2.8.0)
|
38
|
-
simplecov (0.
|
38
|
+
simplecov (0.7.1)
|
39
39
|
multi_json (~> 1.0)
|
40
|
-
simplecov-html (~> 0.
|
41
|
-
simplecov-html (0.
|
42
|
-
sqlite3 (1.3.
|
43
|
-
tzinfo (0.3.
|
40
|
+
simplecov-html (~> 0.7.1)
|
41
|
+
simplecov-html (0.7.1)
|
42
|
+
sqlite3 (1.3.8)
|
43
|
+
tzinfo (0.3.37)
|
44
44
|
|
45
45
|
PLATFORMS
|
46
46
|
ruby
|
47
47
|
|
48
48
|
DEPENDENCIES
|
49
|
-
activerecord (= 3.0.
|
50
|
-
activesupport (= 3.0.
|
49
|
+
activerecord (= 3.0.20)
|
50
|
+
activesupport (= 3.0.20)
|
51
51
|
appraisal (~> 0.4.1)
|
52
52
|
comma!
|
53
53
|
fastercsv
|
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
comma (3.
|
4
|
+
comma (3.2.0)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.2.
|
11
|
-
activesupport (= 3.2.
|
10
|
+
activemodel (3.2.14)
|
11
|
+
activesupport (= 3.2.14)
|
12
12
|
builder (~> 3.0.0)
|
13
|
-
activerecord (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
activerecord (3.2.14)
|
14
|
+
activemodel (= 3.2.14)
|
15
|
+
activesupport (= 3.2.14)
|
16
16
|
arel (~> 3.0.2)
|
17
17
|
tzinfo (~> 0.3.29)
|
18
|
-
activesupport (3.2.
|
19
|
-
i18n (~> 0.6)
|
18
|
+
activesupport (3.2.14)
|
19
|
+
i18n (~> 0.6, >= 0.6.4)
|
20
20
|
multi_json (~> 1.0)
|
21
21
|
appraisal (0.4.1)
|
22
22
|
bundler
|
@@ -25,8 +25,8 @@ GEM
|
|
25
25
|
builder (3.0.4)
|
26
26
|
diff-lcs (1.1.3)
|
27
27
|
fastercsv (1.5.5)
|
28
|
-
i18n (0.6.
|
29
|
-
multi_json (1.
|
28
|
+
i18n (0.6.5)
|
29
|
+
multi_json (1.7.9)
|
30
30
|
rake (0.9.6)
|
31
31
|
rspec (2.8.0)
|
32
32
|
rspec-core (~> 2.8.0)
|
@@ -40,15 +40,15 @@ GEM
|
|
40
40
|
multi_json (~> 1.0)
|
41
41
|
simplecov-html (~> 0.7.1)
|
42
42
|
simplecov-html (0.7.1)
|
43
|
-
sqlite3 (1.3.
|
44
|
-
tzinfo (0.3.
|
43
|
+
sqlite3 (1.3.8)
|
44
|
+
tzinfo (0.3.37)
|
45
45
|
|
46
46
|
PLATFORMS
|
47
47
|
ruby
|
48
48
|
|
49
49
|
DEPENDENCIES
|
50
|
-
activerecord (= 3.2.
|
51
|
-
activesupport (= 3.2.
|
50
|
+
activerecord (= 3.2.14)
|
51
|
+
activesupport (= 3.2.14)
|
52
52
|
appraisal (~> 0.4.1)
|
53
53
|
comma!
|
54
54
|
fastercsv
|
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
comma (3.2.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (3.2.14)
|
11
|
+
i18n (~> 0.6, >= 0.6.4)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
addressable (2.3.5)
|
14
|
+
appraisal (0.4.1)
|
15
|
+
bundler
|
16
|
+
rake
|
17
|
+
bcrypt-ruby (3.1.2)
|
18
|
+
data_mapper (1.2.0)
|
19
|
+
dm-aggregates (~> 1.2.0)
|
20
|
+
dm-constraints (~> 1.2.0)
|
21
|
+
dm-core (~> 1.2.0)
|
22
|
+
dm-migrations (~> 1.2.0)
|
23
|
+
dm-serializer (~> 1.2.0)
|
24
|
+
dm-timestamps (~> 1.2.0)
|
25
|
+
dm-transactions (~> 1.2.0)
|
26
|
+
dm-types (~> 1.2.0)
|
27
|
+
dm-validations (~> 1.2.0)
|
28
|
+
data_objects (0.10.13)
|
29
|
+
addressable (~> 2.1)
|
30
|
+
diff-lcs (1.1.3)
|
31
|
+
dm-aggregates (1.2.0)
|
32
|
+
dm-core (~> 1.2.0)
|
33
|
+
dm-constraints (1.2.0)
|
34
|
+
dm-core (~> 1.2.0)
|
35
|
+
dm-core (1.2.1)
|
36
|
+
addressable (~> 2.3)
|
37
|
+
dm-do-adapter (1.2.0)
|
38
|
+
data_objects (~> 0.10.6)
|
39
|
+
dm-core (~> 1.2.0)
|
40
|
+
dm-migrations (1.2.0)
|
41
|
+
dm-core (~> 1.2.0)
|
42
|
+
dm-serializer (1.2.2)
|
43
|
+
dm-core (~> 1.2.0)
|
44
|
+
fastercsv (~> 1.5)
|
45
|
+
json (~> 1.6)
|
46
|
+
json_pure (~> 1.6)
|
47
|
+
multi_json (~> 1.0)
|
48
|
+
dm-sqlite-adapter (1.2.0)
|
49
|
+
dm-do-adapter (~> 1.2.0)
|
50
|
+
do_sqlite3 (~> 0.10.6)
|
51
|
+
dm-timestamps (1.2.0)
|
52
|
+
dm-core (~> 1.2.0)
|
53
|
+
dm-transactions (1.2.0)
|
54
|
+
dm-core (~> 1.2.0)
|
55
|
+
dm-types (1.2.2)
|
56
|
+
bcrypt-ruby (~> 3.0)
|
57
|
+
dm-core (~> 1.2.0)
|
58
|
+
fastercsv (~> 1.5)
|
59
|
+
json (~> 1.6)
|
60
|
+
multi_json (~> 1.0)
|
61
|
+
stringex (~> 1.4)
|
62
|
+
uuidtools (~> 2.1)
|
63
|
+
dm-validations (1.2.0)
|
64
|
+
dm-core (~> 1.2.0)
|
65
|
+
do_sqlite3 (0.10.13)
|
66
|
+
data_objects (= 0.10.13)
|
67
|
+
fastercsv (1.5.5)
|
68
|
+
i18n (0.6.5)
|
69
|
+
json (1.8.0)
|
70
|
+
json_pure (1.8.0)
|
71
|
+
multi_json (1.7.9)
|
72
|
+
rake (0.9.6)
|
73
|
+
rspec (2.8.0)
|
74
|
+
rspec-core (~> 2.8.0)
|
75
|
+
rspec-expectations (~> 2.8.0)
|
76
|
+
rspec-mocks (~> 2.8.0)
|
77
|
+
rspec-core (2.8.0)
|
78
|
+
rspec-expectations (2.8.0)
|
79
|
+
diff-lcs (~> 1.1.2)
|
80
|
+
rspec-mocks (2.8.0)
|
81
|
+
simplecov (0.7.1)
|
82
|
+
multi_json (~> 1.0)
|
83
|
+
simplecov-html (~> 0.7.1)
|
84
|
+
simplecov-html (0.7.1)
|
85
|
+
sqlite3 (1.3.8)
|
86
|
+
stringex (1.5.1)
|
87
|
+
uuidtools (2.1.4)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
appraisal (~> 0.4.1)
|
94
|
+
comma!
|
95
|
+
data_mapper (= 1.2.0)
|
96
|
+
dm-sqlite-adapter (= 1.2.0)
|
97
|
+
fastercsv
|
98
|
+
rake (~> 0.9.2)
|
99
|
+
rspec (~> 2.8.0)
|
100
|
+
simplecov
|
101
|
+
sqlite3 (~> 1.3.4)
|
@@ -1,39 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
comma (3.
|
4
|
+
comma (3.2.0)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
-
actionmailer (3.0.
|
12
|
-
actionpack (= 3.0.
|
11
|
+
actionmailer (3.0.20)
|
12
|
+
actionpack (= 3.0.20)
|
13
13
|
mail (~> 2.2.19)
|
14
|
-
actionpack (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
14
|
+
actionpack (3.0.20)
|
15
|
+
activemodel (= 3.0.20)
|
16
|
+
activesupport (= 3.0.20)
|
17
17
|
builder (~> 2.1.2)
|
18
18
|
erubis (~> 2.6.6)
|
19
19
|
i18n (~> 0.5.0)
|
20
|
-
rack (~> 1.2.
|
20
|
+
rack (~> 1.2.5)
|
21
21
|
rack-mount (~> 0.6.14)
|
22
22
|
rack-test (~> 0.5.7)
|
23
23
|
tzinfo (~> 0.3.23)
|
24
|
-
activemodel (3.0.
|
25
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.20)
|
25
|
+
activesupport (= 3.0.20)
|
26
26
|
builder (~> 2.1.2)
|
27
27
|
i18n (~> 0.5.0)
|
28
|
-
activerecord (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
28
|
+
activerecord (3.0.20)
|
29
|
+
activemodel (= 3.0.20)
|
30
|
+
activesupport (= 3.0.20)
|
31
31
|
arel (~> 2.0.10)
|
32
32
|
tzinfo (~> 0.3.23)
|
33
|
-
activeresource (3.0.
|
34
|
-
activemodel (= 3.0.
|
35
|
-
activesupport (= 3.0.
|
36
|
-
activesupport (3.0.
|
33
|
+
activeresource (3.0.20)
|
34
|
+
activemodel (= 3.0.20)
|
35
|
+
activesupport (= 3.0.20)
|
36
|
+
activesupport (3.0.20)
|
37
37
|
appraisal (0.4.1)
|
38
38
|
bundler
|
39
39
|
rake
|
@@ -42,38 +42,38 @@ GEM
|
|
42
42
|
diff-lcs (1.1.3)
|
43
43
|
erubis (2.6.6)
|
44
44
|
abstract (>= 1.0.0)
|
45
|
-
fastercsv (1.5.
|
45
|
+
fastercsv (1.5.5)
|
46
46
|
i18n (0.5.0)
|
47
|
-
json (1.
|
48
|
-
mail (2.2.
|
47
|
+
json (1.8.0)
|
48
|
+
mail (2.2.20)
|
49
49
|
activesupport (>= 2.3.6)
|
50
50
|
i18n (>= 0.4.0)
|
51
51
|
mime-types (~> 1.16)
|
52
52
|
treetop (~> 1.4.8)
|
53
|
-
mime-types (1.
|
54
|
-
multi_json (1.
|
53
|
+
mime-types (1.25)
|
54
|
+
multi_json (1.7.9)
|
55
55
|
polyglot (0.3.3)
|
56
|
-
rack (1.2.
|
56
|
+
rack (1.2.8)
|
57
57
|
rack-mount (0.6.14)
|
58
58
|
rack (>= 1.0.0)
|
59
59
|
rack-test (0.5.7)
|
60
60
|
rack (>= 1.0)
|
61
|
-
rails (3.0.
|
62
|
-
actionmailer (= 3.0.
|
63
|
-
actionpack (= 3.0.
|
64
|
-
activerecord (= 3.0.
|
65
|
-
activeresource (= 3.0.
|
66
|
-
activesupport (= 3.0.
|
61
|
+
rails (3.0.20)
|
62
|
+
actionmailer (= 3.0.20)
|
63
|
+
actionpack (= 3.0.20)
|
64
|
+
activerecord (= 3.0.20)
|
65
|
+
activeresource (= 3.0.20)
|
66
|
+
activesupport (= 3.0.20)
|
67
67
|
bundler (~> 1.0)
|
68
|
-
railties (= 3.0.
|
69
|
-
railties (3.0.
|
70
|
-
actionpack (= 3.0.
|
71
|
-
activesupport (= 3.0.
|
68
|
+
railties (= 3.0.20)
|
69
|
+
railties (3.0.20)
|
70
|
+
actionpack (= 3.0.20)
|
71
|
+
activesupport (= 3.0.20)
|
72
72
|
rake (>= 0.8.7)
|
73
73
|
rdoc (~> 3.4)
|
74
74
|
thor (~> 0.14.4)
|
75
|
-
rake (0.9.
|
76
|
-
rdoc (3.12)
|
75
|
+
rake (0.9.6)
|
76
|
+
rdoc (3.12.2)
|
77
77
|
json (~> 1.4)
|
78
78
|
rspec (2.8.0)
|
79
79
|
rspec-core (~> 2.8.0)
|
@@ -88,16 +88,16 @@ GEM
|
|
88
88
|
activesupport (>= 3.0)
|
89
89
|
railties (>= 3.0)
|
90
90
|
rspec (~> 2.8.0)
|
91
|
-
simplecov (0.
|
91
|
+
simplecov (0.7.1)
|
92
92
|
multi_json (~> 1.0)
|
93
|
-
simplecov-html (~> 0.
|
94
|
-
simplecov-html (0.
|
95
|
-
sqlite3 (1.3.
|
93
|
+
simplecov-html (~> 0.7.1)
|
94
|
+
simplecov-html (0.7.1)
|
95
|
+
sqlite3 (1.3.8)
|
96
96
|
thor (0.14.6)
|
97
|
-
treetop (1.4.
|
97
|
+
treetop (1.4.15)
|
98
98
|
polyglot
|
99
99
|
polyglot (>= 0.3.1)
|
100
|
-
tzinfo (0.3.
|
100
|
+
tzinfo (0.3.37)
|
101
101
|
|
102
102
|
PLATFORMS
|
103
103
|
ruby
|
@@ -106,7 +106,7 @@ DEPENDENCIES
|
|
106
106
|
appraisal (~> 0.4.1)
|
107
107
|
comma!
|
108
108
|
fastercsv
|
109
|
-
rails (= 3.0.
|
109
|
+
rails (= 3.0.20)
|
110
110
|
rake (~> 0.9.2)
|
111
111
|
rspec (~> 2.8.0)
|
112
112
|
rspec-rails
|