errata_slip 1.0.0
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 +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +244 -0
- data/Rakefile +6 -0
- data/errata_slip.gemspec +24 -0
- data/lib/errata_slip.rb +49 -0
- data/lib/errata_slip/version.rb +3 -0
- data/spec/errata_slip/errata_slip_spec.rb +124 -0
- data/spec/fixtures/errata.yaml +4 -0
- data/spec/spec_helper.rb +11 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 88a005e10ceb0c161901897acf2c1d0da547f256
|
4
|
+
data.tar.gz: 7b2de1b5b7f817bf3254fdfbbb441b07c09d2373
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 83315ea4d175e6cde80706a5497ccc44d7c912bf3b87ea96560915b47c7254c3ed281b44bd291721c172c3717d84abae26d7267d096230f01a7e33960b0eb43d
|
7
|
+
data.tar.gz: 7c9492566a17aae7f3049e4e91e5281f7ee1f35e5d5ea099c6691ecbe3e4c93a180a2f0c53483970ee414370c04a298296b3d4792f8d1085d9373019a819af0b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Artem Fedorov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
# ErrataSlip [](https://travis-ci.org/artemf/errata_slip) [](https://coveralls.io/r/artemf/errata_slip)
|
2
|
+
|
3
|
+
Apply corrections from yaml file to array of records. Useful in scraping/parsing when one needs to apply errata to the scraped data.
|
4
|
+
|
5
|
+
#### Use case 1 - Easily apply fixes to scraped data
|
6
|
+
|
7
|
+
**errata.yaml:**
|
8
|
+
|
9
|
+
```YAML
|
10
|
+
- city: "LasVegas"
|
11
|
+
~city: "Las Vegas"
|
12
|
+
- city: "LosAngeles"
|
13
|
+
~city: "Los Angeles"
|
14
|
+
```
|
15
|
+
|
16
|
+
**apply_errata.rb:**
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
records = [ { city: 'LasVegas', population: '596424' },
|
20
|
+
{ city: 'LosAngeles', population: '3857799' } ]
|
21
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
22
|
+
p records
|
23
|
+
=> [ { city: 'Las Vegas', population: '596424' },
|
24
|
+
{ city: 'Los Angeles', population: '3857799' } ]
|
25
|
+
```
|
26
|
+
|
27
|
+
#### Use case 2 - Add additional metadata to your data
|
28
|
+
|
29
|
+
**errata.yaml:**
|
30
|
+
|
31
|
+
```YAML
|
32
|
+
- city: "Los Angeles"
|
33
|
+
country: "USA"
|
34
|
+
~state: "California"
|
35
|
+
- city: "Los Angeles"
|
36
|
+
country: "USA"
|
37
|
+
~state: "Nevada"
|
38
|
+
```
|
39
|
+
|
40
|
+
**apply_errata.rb:**
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
records = [ { city: 'Las Vegas', country: 'USA' },
|
44
|
+
{ city: 'Los Angeles', country: 'USA' } ]
|
45
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
46
|
+
p records
|
47
|
+
=> [ { city: 'Las Vegas', country: 'USA', state: 'Nevada' },
|
48
|
+
{ city: 'Los Angeles', country: 'USA', state: 'California' } ]
|
49
|
+
```
|
50
|
+
|
51
|
+
## Installation
|
52
|
+
|
53
|
+
Add this line to your application's Gemfile:
|
54
|
+
|
55
|
+
gem 'errata_slip'
|
56
|
+
|
57
|
+
And then execute:
|
58
|
+
|
59
|
+
$ bundle
|
60
|
+
|
61
|
+
Or install it yourself as:
|
62
|
+
|
63
|
+
$ gem install errata_slip
|
64
|
+
|
65
|
+
## Usage
|
66
|
+
|
67
|
+
You are expected to have array of hashes as an input and corrections are applied to it.
|
68
|
+
|
69
|
+
#### Errata file
|
70
|
+
|
71
|
+
You create ErrataSlip from yaml file with errata
|
72
|
+
```ruby
|
73
|
+
e = ErrataSlip::load_file('errata.yaml')
|
74
|
+
```
|
75
|
+
|
76
|
+
Errata file is array of hashes, which has 'match' fields and 'correct' fields. 'Match' fields are used
|
77
|
+
to find the record to correct, 'correct' fields are used to apply changes to the record. 'Correct' fields
|
78
|
+
are prefixed with tilde (~):
|
79
|
+
|
80
|
+
```YAML
|
81
|
+
- fieldname: "Value of fieldname to find"
|
82
|
+
~fieldname: "Value of fieldname to replace"
|
83
|
+
```
|
84
|
+
|
85
|
+
For example, if your records have key 'name', errata file might look like this:
|
86
|
+
|
87
|
+
```YAML
|
88
|
+
- name: "Name to find"
|
89
|
+
~name: "Name to replace with"
|
90
|
+
```
|
91
|
+
|
92
|
+
'Correct' fields can introduce new fields to your records:
|
93
|
+
|
94
|
+
```YAML
|
95
|
+
- name: "Name to find"
|
96
|
+
~name: "Name to replace with"
|
97
|
+
~applied_errata: true
|
98
|
+
```
|
99
|
+
|
100
|
+
#### Applying errata to all records
|
101
|
+
|
102
|
+
You use correct! method to correct all records in-place
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
scraped_records = [ { :name => 'Adam'}, { :name => 'Eve' } ]
|
106
|
+
ErrataSlip::load_file('errata.yaml').correct!(scraped_records)
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Applying errata to single record
|
110
|
+
|
111
|
+
You use correct_item! method to correct one hash in-place
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
scraped_records = [ { :name => 'Adam'}, { :name => 'Eve' } ]
|
115
|
+
errata = ErrataSlip::load_file('errata.yaml')
|
116
|
+
scraped_records.map { |record| errata.correct_item!(record) }
|
117
|
+
```
|
118
|
+
|
119
|
+
#### Works with both symbolic and string hash keys
|
120
|
+
|
121
|
+
While errata file is written with string hash keys, correction works on both string-keyed hashed and symbol-keyed hashes.
|
122
|
+
|
123
|
+
So it doesn't matter if you have
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
scraped_records = [ { :name => 'Adam'}, { :name => 'Eve' } ]
|
127
|
+
```
|
128
|
+
|
129
|
+
or
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
scraped_records = [ { 'name' => 'Adam'}, { 'name' => 'Eve' } ]
|
133
|
+
```
|
134
|
+
|
135
|
+
ErrataSlip will autodetect format and apply errata correctly.
|
136
|
+
|
137
|
+
## Examples
|
138
|
+
|
139
|
+
#### Easily fix missplelings or inaccuracies in scraped data
|
140
|
+
|
141
|
+
In this example we change all names from 'Adaam' to 'Adam'
|
142
|
+
|
143
|
+
errata.yaml
|
144
|
+
```YAML
|
145
|
+
- name: "Adaam"
|
146
|
+
~name: "Adam"
|
147
|
+
```
|
148
|
+
|
149
|
+
apply_errata.rb
|
150
|
+
```ruby
|
151
|
+
records = [
|
152
|
+
{ name: 'Adaam' },
|
153
|
+
{ name: 'Andrew' }
|
154
|
+
]
|
155
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
156
|
+
p records
|
157
|
+
=> [
|
158
|
+
{ name: 'Adam' },
|
159
|
+
{ name: 'Andrew' }
|
160
|
+
]
|
161
|
+
```
|
162
|
+
|
163
|
+
#### You can match several fields and correct several fields at the same time
|
164
|
+
|
165
|
+
We search for all records with name 'Hillary' and surname 'Clinton' and change them to 'Monika' and 'Lewinsky'
|
166
|
+
respectively.
|
167
|
+
|
168
|
+
errata.yaml
|
169
|
+
```YAML
|
170
|
+
- name: "Hillary"
|
171
|
+
surname: "Clinton"
|
172
|
+
~name: "Monika"
|
173
|
+
~surname: "Lewinsky"
|
174
|
+
```
|
175
|
+
|
176
|
+
apply_errata.rb
|
177
|
+
```ruby
|
178
|
+
records = [
|
179
|
+
{ name: 'Bill', surname: 'Clinton' },
|
180
|
+
{ name: 'Hillary', surname: 'Clinton' }
|
181
|
+
]
|
182
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
183
|
+
p records
|
184
|
+
=> [
|
185
|
+
{ name: 'Bill', surname: 'Clinton' },
|
186
|
+
{ name: 'Monika', surname: 'Lewinsky' }
|
187
|
+
]
|
188
|
+
```
|
189
|
+
|
190
|
+
#### 'Match' fields and 'correct' fields shouldn't be the same
|
191
|
+
|
192
|
+
This example searches all records with name 'Adam' and changes surname to 'Smith' and book to 'The Wealth of Nations'.
|
193
|
+
|
194
|
+
errata.yaml
|
195
|
+
```YAML
|
196
|
+
- name: "Adam"
|
197
|
+
~surname: "Smith"
|
198
|
+
~book: "The Wealth of Nations"
|
199
|
+
```
|
200
|
+
|
201
|
+
apply_errata.rb
|
202
|
+
```ruby
|
203
|
+
records = [
|
204
|
+
{ name: 'Adam', surname: 'Mansbach', book: 'Go the F**k to Sleep' }
|
205
|
+
]
|
206
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
207
|
+
p records
|
208
|
+
=> [
|
209
|
+
{ name: 'Adam', surname: 'Smith', book: 'The Wealth of Nations' }
|
210
|
+
]
|
211
|
+
```
|
212
|
+
|
213
|
+
#### We can not only change existing fields, but also add new ones
|
214
|
+
|
215
|
+
The syntax is the same.
|
216
|
+
|
217
|
+
errata.yaml
|
218
|
+
```YAML
|
219
|
+
- name: "Adam"
|
220
|
+
surname: "Smith"
|
221
|
+
~book: "The Wealth of Nations"
|
222
|
+
```
|
223
|
+
|
224
|
+
apply_errata.rb
|
225
|
+
```ruby
|
226
|
+
records = [
|
227
|
+
{ name: 'Adam', surname: 'Smith' },
|
228
|
+
{ name: 'Adam', surname: 'Mansbach', book: 'Go the F**k to Sleep' }
|
229
|
+
]
|
230
|
+
ErrataSlip::load_file('errata.yaml').correct!(records)
|
231
|
+
p records
|
232
|
+
=> [
|
233
|
+
{ name: 'Adam', surname: 'Smith', book: 'The Wealth of Nations' },
|
234
|
+
{ name: 'Adam', surname: 'Sandler', book: 'Go the F**k to Sleep' }
|
235
|
+
]
|
236
|
+
```
|
237
|
+
|
238
|
+
## Compatibility
|
239
|
+
|
240
|
+
ErrataSlip is tested against MRI 1.9.3, 2.0.0 and 2.1.0
|
241
|
+
|
242
|
+
## Credits
|
243
|
+
|
244
|
+
Artem Fedorov: artemf at mail dot ru
|
data/Rakefile
ADDED
data/errata_slip.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'errata_slip/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "errata_slip"
|
8
|
+
spec.version = ErrataSlip::VERSION
|
9
|
+
spec.authors = ["Artem Fedorov"]
|
10
|
+
spec.email = ["artemf@mail.ru"]
|
11
|
+
spec.summary = %q{Apply corrections from yaml file to array of records}
|
12
|
+
spec.description = %q{Apply corrections from yaml file to array of records. Useful in scraping/parsing when one needs to apply errata to the scraped data.}
|
13
|
+
spec.homepage = "https://github.com/artemf/errata_slip"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
data/lib/errata_slip.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'errata_slip/version'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
class ErrataSlip
|
7
|
+
|
8
|
+
# @return [ErrataSlip]
|
9
|
+
def self.load_file(filename)
|
10
|
+
ErrataSlip.new(YAML::load_file(filename))
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :errata
|
14
|
+
|
15
|
+
def initialize(errata)
|
16
|
+
@errata = errata
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [Array] items -
|
20
|
+
def correct!(items)
|
21
|
+
items.each do |item|
|
22
|
+
correct_item!(item)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def correct_item!(item)
|
27
|
+
@errata.each do |errata|
|
28
|
+
hash_key_is_symbol = nil
|
29
|
+
item.each_key { |k| hash_key_is_symbol = k.is_a?(Symbol); break }
|
30
|
+
next unless item_matches_errata(item, errata, hash_key_is_symbol)
|
31
|
+
change_fields = errata.keys.select { |field| field[0] == '~' }
|
32
|
+
change_fields.map! { |field| field[1..-1]}
|
33
|
+
change_fields.each do |field|
|
34
|
+
hash_field = hash_key_is_symbol ? field.to_sym : field
|
35
|
+
item[hash_field] = errata["~#{field}"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
item
|
39
|
+
end
|
40
|
+
|
41
|
+
def item_matches_errata(hash, errata, hash_key_is_symbol = false)
|
42
|
+
find_fields = errata.keys.select { |field| field[0] != '~' }
|
43
|
+
find_fields.each do |key|
|
44
|
+
hash_key = hash_key_is_symbol ? key.to_sym : key
|
45
|
+
return false if hash[hash_key] != errata[key]
|
46
|
+
end
|
47
|
+
true
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe ErrataSlip do
|
6
|
+
|
7
|
+
context '.correct_item!' do
|
8
|
+
|
9
|
+
tests =
|
10
|
+
[
|
11
|
+
{
|
12
|
+
it: 'should not correct when errata doesn' 't match',
|
13
|
+
errata: [{ 'name' => 'Adam', '~name' => 'Brian' }],
|
14
|
+
item: { 'name' => 'NoSuchName' },
|
15
|
+
expected: { 'name' => 'NoSuchName' }
|
16
|
+
},
|
17
|
+
{
|
18
|
+
it: 'should change fields',
|
19
|
+
errata: [{ 'name' => 'Adam', '~name' => 'Brian' }],
|
20
|
+
item: { 'name' => 'Adam' },
|
21
|
+
expected: { 'name' => 'Brian' }
|
22
|
+
},
|
23
|
+
{
|
24
|
+
it: 'should leave unmentioned fields intact',
|
25
|
+
errata: [{ 'name' => 'Adam', '~name' => 'Brian' }],
|
26
|
+
item: { 'name' => 'Adam', 'surname' => 'Other' },
|
27
|
+
expected: { 'name' => 'Brian', 'surname' => 'Other' }
|
28
|
+
},
|
29
|
+
{
|
30
|
+
it: 'should add new fields',
|
31
|
+
errata: [{ 'name' => 'Adam', '~country' => 'Honduras' }],
|
32
|
+
item: { 'name' => 'Adam' },
|
33
|
+
expected: { 'name' => 'Adam', 'country' => 'Honduras' }
|
34
|
+
},
|
35
|
+
{
|
36
|
+
it: 'should change (symbolic) fields',
|
37
|
+
errata: [{ 'name' => 'Adam', '~name' => 'Brian' }],
|
38
|
+
item: { :name => 'Adam' },
|
39
|
+
expected: { :name => 'Brian' }
|
40
|
+
},
|
41
|
+
{
|
42
|
+
it: 'should add new (symbolic) fields',
|
43
|
+
errata: [{ 'name' => 'Adam', '~country' => 'Honduras' }],
|
44
|
+
item: { :name => 'Adam' },
|
45
|
+
expected: { :name => 'Adam', :country => 'Honduras' }
|
46
|
+
},
|
47
|
+
{
|
48
|
+
it: 'should match multiple fields',
|
49
|
+
errata: [{ 'name' => 'Adam', 'surname' => 'Smith', '~name' => 'Brian' }],
|
50
|
+
item: { 'name' => 'Adam', 'surname' => 'Smith' },
|
51
|
+
expected: { 'name' => 'Brian', 'surname' => 'Smith' }
|
52
|
+
},
|
53
|
+
{
|
54
|
+
it: 'should not match partial multiple fields matches',
|
55
|
+
errata: [{ 'name' => 'Adam', 'surname' => 'Smith', '~name' => 'Brian' }],
|
56
|
+
item: { 'name' => 'Adam', 'surname' => 'Klien' },
|
57
|
+
expected: { 'name' => 'Adam', 'surname' => 'Klien' }
|
58
|
+
}
|
59
|
+
|
60
|
+
]
|
61
|
+
|
62
|
+
tests.each do |test|
|
63
|
+
it test[:it] do
|
64
|
+
ErrataSlip.new(test[:errata]).correct_item!(test[:item])
|
65
|
+
test[:item].should eq test[:expected]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return the modified item too' do
|
70
|
+
errata = [ { 'name' => 'Adam', '~name' => 'Brian' } ]
|
71
|
+
item = { 'name' => 'Adam' }
|
72
|
+
expected = { 'name' => 'Brian' }
|
73
|
+
result = ErrataSlip.new(errata).correct_item!(item)
|
74
|
+
result.should eq expected
|
75
|
+
item.should eq expected
|
76
|
+
result.should eq item
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
context '.correct!' do
|
82
|
+
let(:errata) { [{ 'name' => 'Adam', '~name' => 'Brian' }, { 'name' => 'Arthur', '~name' => 'Bob' }] }
|
83
|
+
let(:input) { [{ 'name' => 'Adam' }, { 'name' => 'Arthur' }] }
|
84
|
+
let(:expected) { [{ 'name' => 'Brian' }, { 'name' => 'Bob' }] }
|
85
|
+
|
86
|
+
it 'should change fields' do
|
87
|
+
ErrataSlip.new(errata).correct!(input)
|
88
|
+
input.should eq expected
|
89
|
+
end
|
90
|
+
|
91
|
+
let(:input) { [{ 'name' => 'Adam' }, { 'name' => 'Arthur' }, { 'name' => 'Alex' }] }
|
92
|
+
let(:expected) { [{ 'name' => 'Brian' }, { 'name' => 'Bob' }, { 'name' => 'Alex' }] }
|
93
|
+
|
94
|
+
it 'should change fields, except when errata doesn' 't match' do
|
95
|
+
ErrataSlip.new(errata).correct!(input)
|
96
|
+
input.should eq expected
|
97
|
+
end
|
98
|
+
|
99
|
+
let(:errata) { [{ 'name' => 'Adam', '~country' => 'Honduras' }, { 'name' => 'Arthur', '~country' => 'Guatemala' }] }
|
100
|
+
let(:expected) { [{ 'name' => 'Adam', 'country' => 'Honduras' }, { 'name' => 'Arthur', 'country' => 'Guatemala' }, { 'name' => 'Alex' }] }
|
101
|
+
|
102
|
+
it 'should add new fields, except when errata doesn' 't match' do
|
103
|
+
ErrataSlip.new(errata).correct!(input)
|
104
|
+
input.should eq expected
|
105
|
+
end
|
106
|
+
|
107
|
+
let(:errata) { [{ 'name' => 'Adam', '~name' => 'Brian' }, { 'name' => 'Arthur', '~country' => 'Guatemala' }] }
|
108
|
+
let(:expected) { [{ 'name' => 'Brian' }, { 'name' => 'Arthur', 'country' => 'Guatemala' }, { 'name' => 'Alex' }] }
|
109
|
+
|
110
|
+
it 'should both change fields and add new fields' do
|
111
|
+
ErrataSlip.new(errata).correct!(input)
|
112
|
+
input.should eq expected
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context '::load_file' do
|
118
|
+
it 'should load errata from file' do
|
119
|
+
expected_errata = [{ 'name' => 'Adam', '~name' => 'Brian' }, { 'name' => 'Arthur', '~name' => 'Bob' }]
|
120
|
+
slip = ErrataSlip::load_file(File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'errata.yaml')))
|
121
|
+
slip.errata.should eq expected_errata
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: errata_slip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artem Fedorov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Apply corrections from yaml file to array of records. Useful in scraping/parsing
|
56
|
+
when one needs to apply errata to the scraped data.
|
57
|
+
email:
|
58
|
+
- artemf@mail.ru
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- errata_slip.gemspec
|
70
|
+
- lib/errata_slip.rb
|
71
|
+
- lib/errata_slip/version.rb
|
72
|
+
- spec/errata_slip/errata_slip_spec.rb
|
73
|
+
- spec/fixtures/errata.yaml
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
homepage: https://github.com/artemf/errata_slip
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.2.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Apply corrections from yaml file to array of records
|
99
|
+
test_files:
|
100
|
+
- spec/errata_slip/errata_slip_spec.rb
|
101
|
+
- spec/fixtures/errata.yaml
|
102
|
+
- spec/spec_helper.rb
|