stockboy 0.5.0 → 0.5.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: 9084ee54795b124c1f8d696f121f9bf2c157d203
4
- data.tar.gz: e55ec14784707d3c7faa55339a23d2f27832f33d
3
+ metadata.gz: 4f4c7e5f39621bb22f09bd06f634cb49023d6d6c
4
+ data.tar.gz: 0bc7683c74a66cc5a9510cde44c2ed15a62a64e7
5
5
  SHA512:
6
- metadata.gz: b2aee64506bd8ac04e4e8cd110fe882b6722e11eeae34ddcb7bfb2f1882615a1d9b82f621ee01ef45ae234ad98b2019bbdfd1e7ec2d2dd6f911e160d30ab4e32
7
- data.tar.gz: 70429f68f99fbfb65dfa8cc24bb2c0e20a4a49b6a33b3147ab9e8feeb542fff794d2f45ce3d94d2ab9a168998d52ca7d07881b6b5a8b23aaaf7ed786946b831d
6
+ metadata.gz: 92b3a6d076053c21f48df30fbd544bf2ac952b9fd336a4080466e1b190a632216fc07f59f64756c79238a6304d84fb49e182f1119e6ed1e85376991b4e08cb9d
7
+ data.tar.gz: cc0a187e65ed56537ca104d23a42a359d064cae1aa6378605d4c60fb4b7c810956a6997f14518f6d710732f8ff4de393be5766bbe3426abad8ca76b985069d16
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ bundler_args: --without debug --without doc
3
+ env:
4
+ - CI=true
5
+ rvm:
6
+ - "1.9.3"
7
+ - "2.0.0"
8
+ - "jruby-19mode"
9
+ - "rbx"
10
+ script: bundle exec rspec spec
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: "rbx"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1 / 2013-12-03
4
+
5
+ [ENHANCEMENT] Link to full documentation and license
6
+ [ENHANCEMENT] Add CI test environment and code metrics
7
+
3
8
  ## 0.5.0 / 2013-12-03
4
9
 
5
10
  [FEATURE] YARD documentation throughout
data/Gemfile CHANGED
@@ -1,12 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- group :debug do
5
- gem "pry"
6
- gem "pry-debugger"
4
+ unless ENV["CI"]
5
+ group :debug do
6
+ gem "pry"
7
+ gem "pry-debugger"
8
+ end
7
9
  end
8
10
 
9
- group :quality do
11
+ group :doc do
10
12
  gem "redcarpet", "~> 1.0"
11
13
  gem "yard"
12
14
  end
15
+
16
+ platforms :rbx do
17
+ gem "rubysl-tracer", "~> 2.0"
18
+ gem "rubysl", "~> 2.0"
19
+ gem "racc"
20
+ end
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # Stockboy
2
2
 
3
+ [![Build Status](https://travis-ci.org/avit/stockboy.png)][travis]
4
+ [![Code Climate](https://codeclimate.com/github/avit/stockboy.png)][climate]
5
+
3
6
  Stockboy helps you receive and unpack data onto your shelves. You might
4
7
  consider using it to synchronize data exported from external sources, or
5
8
  migrating your own data from legacy systems. (TL;DR, Stockboy is a Ruby
6
9
  [DSL][dsl] for doing [ETL][etl].)
7
10
 
11
+ Full documentation available at [rdoc.info/gems/stockboy][rdoc]
8
12
 
9
13
  ## Goals
10
14
 
@@ -239,6 +243,25 @@ output values from the second block parameter:
239
243
  input["RawEmailAddress"] =~ /gmail/ or output.bounce_count > 1
240
244
  end
241
245
 
246
+ ### 5. Trigger it with actions
247
+
248
+ Also optional, triggers let you define an action in the job template context
249
+ that can be called from your application. This lets you separate your app
250
+ interface from the implementation details of each data source.
251
+
252
+ A typical use case might be to clean up stale data after a successful import:
253
+
254
+ on :cleanup do |job, timestamp|
255
+ next unless job.processed?
256
+ job.provider.client do |ftp|
257
+ ftp.put(StringIO.new(timestamp.to_s), "LAST_RUN")
258
+ end
259
+ job.provider.delete_data # deletes the last matching file used
260
+ end
261
+
262
+ The action blocks receive the job instance, and any additional arguments when
263
+ called via `job.trigger(:cleanup, Time.now)` or simply `job.cleanup(Time.now)`.
264
+
242
265
  ---
243
266
 
244
267
  ## Installation
@@ -291,3 +314,6 @@ Contributions and pull requests are welcome.
291
314
  [gf]: http://guestfolio.com/
292
315
  [etl]: https://en.wikipedia.org/wiki/Extract,_transform,_load
293
316
  [dsl]: https://en.wikipedia.org/wiki/Domain-specific_language
317
+ [travis]: https://travis-ci.org/avit/stockboy
318
+ [climate]: https://codeclimate.com/github/avit/stockboy
319
+ [rdoc]: http://rdoc.info/gems/stockboy/frames
@@ -1,3 +1,5 @@
1
+ require 'logger'
2
+
1
3
  module Stockboy
2
4
 
3
5
  # Global Stockboy configuration options
@@ -168,7 +168,7 @@ module Stockboy
168
168
  # current_match : best_match
169
169
  # end
170
170
  #
171
- def pick_from(list, &block)
171
+ def pick_from(list)
172
172
  case @pick
173
173
  when Symbol
174
174
  list.public_send @pick
@@ -63,7 +63,7 @@ module Stockboy::Providers
63
63
  when String
64
64
  Dir[::File.join(file_dir, file_name)]
65
65
  end
66
- @matching_file = pick_file_from(files) if files.any?
66
+ @matching_file = pick_from(files) if files.any?
67
67
  end
68
68
 
69
69
  def clear
@@ -91,15 +91,6 @@ module Stockboy::Providers
91
91
  errors.empty?
92
92
  end
93
93
 
94
- def pick_file_from(list)
95
- case @pick
96
- when Symbol
97
- list.public_send @pick
98
- when Proc
99
- list.detect &@pick
100
- end
101
- end
102
-
103
94
  def picked_matching_file?
104
95
  !!@matching_file
105
96
  end
@@ -1,3 +1,3 @@
1
1
  module Stockboy
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
- require 'pry'
2
- require 'pry-debugger'
1
+ if $DEBUG && !ENV['CI']
2
+ require 'pry'
3
+ require 'pry-debugger'
4
+ end
5
+
3
6
  require 'ostruct'
4
7
  require 'savon'
5
8
  require 'savon/mock/spec_helper'
@@ -93,20 +93,21 @@ module Stockboy
93
93
  describe ".delete_data" do
94
94
  let(:target) { ::Tempfile.new(['delete', '.csv']) }
95
95
  let(:target_dir) { File.dirname(target) }
96
- subject(:provider) { Providers::File.new(file_name: 'delete*.csv', file_dir: target_dir) }
96
+ let(:pick_same) { ->(best, this) { this == target.path ? this : best } }
97
97
 
98
- after do
99
- target.unlink
98
+ subject(:provider) do
99
+ Providers::File.new(file_name: 'delete*.csv', file_dir: target_dir, pick: pick_same)
100
100
  end
101
101
 
102
102
  it "should raise an error when called blindly" do
103
- expect_any_instance_of(::File).to_not receive(:delete)
104
103
  expect { provider.delete_data }.to raise_error Stockboy::OutOfSequence
105
104
  end
106
105
 
107
106
  it "should call delete on the matched file" do
108
107
  provider.matching_file
109
108
 
109
+ non_matching_duplicate = ::Tempfile.new(['delete', '.csv'])
110
+
110
111
  expect(::File).to receive(:delete).with(target.path)
111
112
  provider.delete_data
112
113
  end
data/stockboy.gemspec CHANGED
@@ -7,7 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.version = Stockboy::VERSION
8
8
  s.authors = ["Andrew Vit"]
9
9
  s.email = ["andrew@avit.ca"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/avit/stockboy"
11
+ s.license = "MIT"
11
12
  s.summary = %q{Multi-source data normalization library}
12
13
  s.description = %q{Supports importing data over various transports with key-value remapping & normalization}
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Vit
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
120
  - .rspec
121
+ - .travis.yml
121
122
  - .yardopts
122
123
  - CHANGELOG.md
123
124
  - Gemfile
@@ -226,8 +227,9 @@ files:
226
227
  - spec/stockboy/translations_spec.rb
227
228
  - spec/stockboy/translator_spec.rb
228
229
  - stockboy.gemspec
229
- homepage: ''
230
- licenses: []
230
+ homepage: https://github.com/avit/stockboy
231
+ licenses:
232
+ - MIT
231
233
  metadata: {}
232
234
  post_install_message:
233
235
  rdoc_options: []