cascade-rb 0.2.2 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/cascade/row_processor.rb +1 -1
- data/lib/cascade/version.rb +1 -1
- data/spec/lib/row_processor_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c6aadcd330b397cf46bd735ec764579c5a221d
|
4
|
+
data.tar.gz: a3e28fcdd18696b60c7ac067f3cbbfc87fa5acca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a4a9bd0fb79bbe8e23f7ef0255c5ea0b650018325189ac2204aa2281de0cf75933ab475a18cc7c0c310dc0748c7dd7a84c84f37453a3dec5c9c38a6badd005b
|
7
|
+
data.tar.gz: 556e36c7e5c1d20f2f17fe69c36e9596297820d2c92b6bf8e5c9664d949b9065dea650fbdde1baaf2e1d1e1a816713b0b036c2027d4746db2a1003b16cf875f8
|
data/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
[](https://codeship.com/projects/63625) [](https://codeclimate.com/github/ignat-zakrevsky/cascade) [](https://codeclimate.com/github/ignat-zakrevsky/cascade) [](http://badge.fury.io/rb/cascade-rb) [](https://www.codacy.com/app/iezakrevsky/cascade)
|
4
4
|
|
5
|
-
The main
|
6
|
-
Usually, parsing
|
5
|
+
The main goal of this gem is to provide some kind of template for parsing files.
|
6
|
+
Usually, file parsing process consists of the following steps:
|
7
7
|
|
8
|
-
1.
|
8
|
+
1. Retrieve info from file
|
9
9
|
2. Distinguish content from each file line
|
10
10
|
3. Parse each column with corresponding parser
|
11
11
|
4. Generate some kind of data record
|
@@ -52,26 +52,26 @@ Cascade.configuration do
|
|
52
52
|
end
|
53
53
|
```
|
54
54
|
|
55
|
-
Provide
|
55
|
+
Provide enumerable object for parsing and run it!
|
56
56
|
```ruby
|
57
57
|
Cascade::DataParser.new(data_provider: Csv.open("data_test.csv")).call
|
58
58
|
```
|
59
59
|
|
60
60
|
## Columns mapping
|
61
|
-
Parsing file description should have
|
61
|
+
Parsing file description should have the following structure [(example)](https://github.com/ignat-zakrevsky/cascade-example/blob/master/columns_mapping.yml)
|
62
62
|
```yaml
|
63
63
|
mapping:
|
64
64
|
name: type
|
65
65
|
```
|
66
66
|
|
67
67
|
## Columns parsing
|
68
|
-
There are several
|
68
|
+
There are already several defined field parsers (types):
|
69
69
|
|
70
70
|
- currency
|
71
71
|
- boolean
|
72
72
|
- string
|
73
73
|
|
74
|
-
Feel free to add new
|
74
|
+
Feel free to add new field parsers through PR.
|
75
75
|
|
76
76
|
## Components replaceability
|
77
77
|
There is a lot of DI in this gem, so, you can replace each component of the parser. Let's assume you want to parse JSON files instead of CSV, save this to ActiveRecord model, and you need Date fields parsing, ok!
|
@@ -8,7 +8,7 @@ module Cascade
|
|
8
8
|
extend Configuration
|
9
9
|
using HashRefinements
|
10
10
|
|
11
|
-
DEFAULT_PROCESSOR = ->(value) { value }
|
11
|
+
DEFAULT_PROCESSOR = ->(value) { value && value.to_s.strip }
|
12
12
|
|
13
13
|
define_setting :use_default_presenter, false
|
14
14
|
define_setting :deafult_presenter, -> { DEFAULT_PROCESSOR }
|
data/lib/cascade/version.rb
CHANGED
@@ -26,7 +26,7 @@ describe Cascade::RowProcessor do
|
|
26
26
|
it "collect row values with corresponding keys" do
|
27
27
|
processed_row = described_class.new(columns_matching:
|
28
28
|
columns_matching).call(row)
|
29
|
-
assert_equal(processed_row, a:
|
29
|
+
assert_equal(processed_row, a: "a_value", b: "b_value", c: "c_value")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascade-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignat Zakrevsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|