stockboy 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 887af38181777e9ac5c5bd9dc2d72c964be88e19
4
- data.tar.gz: 9db5d875d0d77a3baa99ba7d2589f3257daf2e65
3
+ metadata.gz: db81b34ead77c1f6fffbb45024f491c55629fcbc
4
+ data.tar.gz: a9550b87a91852566538b53b093a15b4e947848a
5
5
  SHA512:
6
- metadata.gz: be4fcd3c97be1a1ca55942d486c1cc6c13c328f06bed609347b907e135fe7bcb53790e4e88b4867b96c281d2ad6dcd8ab3668a62de6865528b7271a8c25a58ae
7
- data.tar.gz: 248d7903b7de6fa4debd7a0b0f6d8d1dab83761e1efafda1d0a928c6cba20a2ce2c905298bcc3194ed72d9125c200e658ae29c6442777cc2b7ded71a3f939e84
6
+ metadata.gz: ff71d14c0227d969fca699b2a40439855600d4176174073ba4d2679b790d77694ae740489622a791989fb04e92215c0bb49e21ba5c524a156f780d6b234cbe8c
7
+ data.tar.gz: a8a4c0b192d096253b5e68ae1ac3e58dc69a66dc2dbad3f44cfacffb9d886f5d2a2899ff252ec3dbe8e12ddd338f8da76938819a701d88df5f28ad5b968ccbd9
data/.travis.yml CHANGED
@@ -4,7 +4,9 @@ env:
4
4
  - CI=true
5
5
  rvm:
6
6
  - "1.9.3"
7
- - "2.1.1"
7
+ - "2.0.0"
8
+ - "2.1"
9
+ - "2.2"
8
10
  - "rbx"
9
11
  - "jruby-head"
10
12
  before_install:
@@ -13,6 +15,8 @@ script: bundle exec rspec spec
13
15
  matrix:
14
16
  fast_finish: true
15
17
  allow_failures:
18
+ - rvm: "1.9.3"
19
+ - rvm: "2.0.0"
16
20
  - rvm: "rbx"
17
21
  - rvm: "jruby-head"
18
22
  addons:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 / 2015-12-16
4
+
5
+ * [ENHANCEMENT] Add `:json` as a standard registered reader
6
+ * [ENHANCEMENT] Allow `ignore: true` to always remove virtual attributes
7
+
3
8
  ## 1.0.0 / 2015-06-30
4
9
 
5
10
  We've been running this happily in production for many months. I think it's
@@ -8,19 +13,19 @@ about time to give it a version number to reflect that.
8
13
  ## 0.11.1 / 2015-04-13
9
14
 
10
15
  * [BUGFIX] Option to set POST body works correctly
11
-
16
+
12
17
  ## 0.11.0 / 2015-04-13
13
18
 
14
19
  * [FEATURE] Options to set POST body and headers
15
-
20
+
16
21
  ## 0.10.0 / 2015-01-23
17
22
 
18
23
  * [FEATURE] Option to ignore unwanted attributes from output
19
-
24
+
20
25
  ## 0.9.0 / 2014-05-19
21
26
 
22
- * [FEATURE] Add JSON reader
23
-
27
+ * [FEATURE] Add JSON reader
28
+
24
29
  ## 0.8.1 / 2014-04-24
25
30
 
26
31
  * [BUGFIX] Support `data_size` for non-string providers
@@ -107,4 +112,3 @@ about time to give it a version number to reflect that.
107
112
  ## 0.4.1 / 2013-11-19
108
113
 
109
114
  First post!
110
-
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Stockboy helps you receive and unpack data onto your shelves. It provides a DSL
9
9
  for configuring data processing pipelines. You might consider using it to
10
10
  synchronize data exported from external sources, as part of an [ETL][etl]
11
- workflow, or migrating your own data from legacy systems.
11
+ workflow, or migrating your own data from legacy systems.
12
12
 
13
13
  Full documentation available at [rdoc.info/gems/stockboy][rdoc]
14
14
 
@@ -21,14 +21,14 @@ ways. Each data source might vary orthogonally on:
21
21
  * __Where the data resides:__
22
22
  whether a SOAP service, sent to an IMAP mailbox, an FTP server, or simply a
23
23
  local file.
24
- * __How the data is formatted:__
24
+ * __How the data is formatted:__
25
25
  whether CSV, Excel, XML, JSON, or some other obscure format.
26
- * __How the records are structured:__
26
+ * __How the records are structured:__
27
27
  what fields are included, and how they are named.
28
- * __What format the fields are:__
28
+ * __What format the fields are:__
29
29
  such as different date formats (DMY vs. MDY), whether names are "first,
30
30
  last", or what do do with missing values.
31
- * __Which records to process:__
31
+ * __Which records to process:__
32
32
  selecting whether records are incomplete, or valid and needing to be added,
33
33
  updated or deleted.
34
34
 
@@ -117,7 +117,7 @@ Writing a job template requires you to declare three parts:
117
117
  filter(:invalid_email) do |input, _|
118
118
  not(input.email.include?('@') or input['EmailAddress'] == '')
119
119
  end
120
-
120
+
121
121
  filter(:missing_code) do |_, output|
122
122
  output.product_code.nil?
123
123
  end
@@ -145,7 +145,7 @@ data set.
145
145
  loop do
146
146
  inputs << http_provider
147
147
  break if http_provider.data.split("\n").size < 100
148
- http_provider.query["page"] += 1
148
+ http_provider.query["page"] += 1
149
149
  end
150
150
  end
151
151
 
@@ -215,13 +215,15 @@ If a field needs to be omitted when exporting to hash (to avoid downstream
215
215
  clients clobbering existing values with nil), specify the option with a
216
216
  callable object or a symbol that can be called against the output field value:
217
217
 
218
+ title ignore: true
218
219
  email ignore: ->(r) { not r.email.include?("@") }
219
220
  score ignore: :zero?
220
221
 
222
+
221
223
  The callable object receives the whole record context like when translating
222
224
  with the "as" option.
223
225
 
224
- #### Built-in attribute translators:
226
+ #### Built-in attribute translators:
225
227
 
226
228
  * [`:boolean`][bool]
227
229
  Common true/false strings to `True` or `False` (e.g. '1'/'0' or 't'/'f')
@@ -231,7 +233,7 @@ with the "as" option.
231
233
  Date strings from UK format to `Date` (e.g. "DD/MM/YY")
232
234
  * [`:us_date`][usda]
233
235
  Date strings from US format to `Date` (e.g. "MM/DD/YY")
234
- * [`:decimal`][deci]
236
+ * [`:decimal`][deci]
235
237
  Numeric strings to `BigDecimal` (e.g. prices)
236
238
  * [`:integer`][intg]
237
239
  Numeric strings to `Fixnum` integers
@@ -265,7 +267,7 @@ individually as `attribute :name`.
265
267
  Filters are optional, but they are very helpful for funneling the data into
266
268
  your workflow. For example, you may need to partition records for different
267
269
  handling based on a status field.
268
-
270
+
269
271
  Filters are applied in the order that they are declared. The first filter that
270
272
  returns `true` when traversing a record will capture it. Records that fall
271
273
  through all the filters without matching anything are considered "unfiltered".
@@ -304,9 +306,9 @@ called via `job.trigger(:cleanup, Time.now)` or simply `job.cleanup(Time.now)`.
304
306
 
305
307
  ---
306
308
 
307
- ## Installation
309
+ ## Installation
308
310
 
309
- Add `gem 'stockboy'` to your Gemfile and run `bundle install`.
311
+ Add `gem 'stockboy'` to your Gemfile and run `bundle install`.
310
312
 
311
313
  Supported on Ruby 1.9+.
312
314
 
@@ -352,7 +354,7 @@ Contributions and pull requests are welcome.
352
354
  bundle exec rake # runs tests
353
355
 
354
356
  [gf]: http://guestfolio.com/
355
- [etl]: https://en.wikipedia.org/wiki/Extract,_transform,_load
357
+ [etl]: https://en.wikipedia.org/wiki/Extract,_transform,_load
356
358
  [dsl]: https://en.wikipedia.org/wiki/Domain-specific_language
357
359
  [travis]: https://travis-ci.org/avit/stockboy
358
360
  [gemnasium]: https://gemnasium.com/avit/stockboy
data/lib/stockboy.rb CHANGED
@@ -36,6 +36,7 @@ require 'stockboy/providers/file'
36
36
 
37
37
  # Readers
38
38
  require 'stockboy/readers/csv'
39
+ require 'stockboy/readers/json'
39
40
  require 'stockboy/readers/xml'
40
41
  require 'stockboy/readers/fixed_width'
41
42
  require 'stockboy/readers/spreadsheet'
@@ -56,6 +57,7 @@ module Stockboy
56
57
 
57
58
  module Readers
58
59
  register :csv, CSV
60
+ register :json, JSON
59
61
  register :xml, XML
60
62
  register :fixed_width, FixedWidth
61
63
  register :spreadsheet, Spreadsheet
@@ -10,7 +10,7 @@ module Stockboy
10
10
  elsif ignore_condition.respond_to?(:call)
11
11
  ignore_condition.call(context)
12
12
  else
13
- false
13
+ !!(ignore_condition)
14
14
  end
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Stockboy
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -20,6 +20,11 @@ module Stockboy
20
20
  attr.ignore?(double email: "@").should be false
21
21
  end
22
22
 
23
+ it "is true with a truthy value" do
24
+ attr = Attribute.new :email, "email", [], 1
25
+ attr.ignore?(double email: "").should be true
26
+ end
27
+
23
28
  it "yields records to a proc" do
24
29
  attr = Attribute.new :email, "email", [], ->(r) { not r.email.include? "@" }
25
30
  attr.ignore?(double email: "").should be true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Vit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake