conformist 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/README.md +18 -6
- data/lib/conformist/schema.rb +1 -0
- data/lib/conformist/version.rb +1 -1
- data/test/unit/conformist/schema_test.rb +7 -0
- metadata +9 -9
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.1.3 / 2012-02-09
|
4
|
+
|
5
|
+
* Column indexes are implicitly incremented when the index argument is omitted. Implicit indexing is all or nothing.
|
6
|
+
|
3
7
|
## 0.1.2 / 2012-01-19
|
4
8
|
|
5
9
|
* `Conformist::Builder` coerces enumerables into an Array. Works with Spreadsheet for conforming Microsoft Excel spreadsheets.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Conformist
|
1
|
+
# Conformist
|
2
2
|
|
3
3
|
[](http://travis-ci.org/tatey/conformist)
|
4
4
|
|
@@ -8,7 +8,7 @@ Bend CSVs to your will with declarative schemas. Map one or many columns, prepro
|
|
8
8
|
|
9
9
|
## Quick and Dirty Examples
|
10
10
|
|
11
|
-
Open a CSV file and declare a schema.
|
11
|
+
Open a CSV file and declare a schema. A schema compromises of columns. A column takes an arbitary name followed by its position in the input. A column may be derived from multiple positions.
|
12
12
|
|
13
13
|
``` ruby
|
14
14
|
require 'conformist'
|
@@ -137,7 +137,7 @@ Class schemas are explicit. Class schemas were the only type available in earlie
|
|
137
137
|
``` ruby
|
138
138
|
class Citizen
|
139
139
|
extend Conformist
|
140
|
-
|
140
|
+
|
141
141
|
column :name, 0, 1
|
142
142
|
column :email, 2
|
143
143
|
end
|
@@ -145,6 +145,18 @@ end
|
|
145
145
|
Citizen.conform [['Tate', 'Johnson', 'tate@tatey.com']]
|
146
146
|
```
|
147
147
|
|
148
|
+
### Implicit Indexing
|
149
|
+
|
150
|
+
Column indexes are implicitly incremented when the index argument is omitted. Implicit indexing is all or nothing.
|
151
|
+
|
152
|
+
``` ruby
|
153
|
+
column :account_number # => 0
|
154
|
+
column :date { |v| Time.new *v.split('/').reverse } # => 1
|
155
|
+
column :description # => 2
|
156
|
+
column :debit # => 3
|
157
|
+
column :credit # => 4
|
158
|
+
```
|
159
|
+
|
148
160
|
### Conform
|
149
161
|
|
150
162
|
Conform is the principle method for lazily applying a schema to the given input.
|
@@ -231,7 +243,7 @@ end
|
|
231
243
|
Virtual columns are not sourced from input. Omit the index to create a virtual column. Like real columns, virtual columns are included in the conformed output.
|
232
244
|
|
233
245
|
``` ruby
|
234
|
-
column :day do
|
246
|
+
column :day do
|
235
247
|
1
|
236
248
|
end
|
237
249
|
```
|
@@ -316,14 +328,14 @@ See CHANGELOG.md for a full list of changes.
|
|
316
328
|
|
317
329
|
## Dependancies
|
318
330
|
|
319
|
-
No explicit dependencies, although `CSV`
|
331
|
+
No explicit dependencies, although `CSV` and `Spreadsheet` are commonly used.
|
320
332
|
|
321
333
|
## Contributing
|
322
334
|
|
323
335
|
1. Fork
|
324
336
|
2. Install dependancies by running `$ bundle install`
|
325
337
|
3. Write tests and code
|
326
|
-
4. Make sure the tests pass by running `$ rake`
|
338
|
+
4. Make sure the tests pass by running `$ bundle exec rake`
|
327
339
|
5. Push and send a pull request on GitHub
|
328
340
|
|
329
341
|
## Motivation
|
data/lib/conformist/schema.rb
CHANGED
data/lib/conformist/version.rb
CHANGED
@@ -45,6 +45,13 @@ class Conformist::SchemaTest < MiniTest::Unit::TestCase
|
|
45
45
|
assert_equal 2, definition.columns.size
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_column_with_implict_index
|
49
|
+
definition = Class.new { extend Schema }
|
50
|
+
definition.column :a
|
51
|
+
definition.column :b
|
52
|
+
assert_equal [0, 1], definition.columns.map { |column| column.indexes }.flatten
|
53
|
+
end
|
54
|
+
|
48
55
|
def test_conform_returns_enumerable
|
49
56
|
definition = Class.new { extend Schema }
|
50
57
|
assert definition.conform([]).respond_to?(:each)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conformist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70317078761180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70317078761180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70317078759240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70317078759240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: spreadsheet
|
38
|
-
requirement: &
|
38
|
+
requirement: &70317078758780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70317078758780
|
47
47
|
description: Bend CSVs to your will with declarative schemas.
|
48
48
|
email:
|
49
49
|
- tate@tatey.com
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash: -
|
106
|
+
hash: -2607692248856246044
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project: conformist
|
109
109
|
rubygems_version: 1.8.11
|