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 +4 -4
- data/.travis.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -4
- data/README.md +26 -0
- data/lib/stockboy/configuration.rb +2 -0
- data/lib/stockboy/provider.rb +1 -1
- data/lib/stockboy/providers/file.rb +1 -10
- data/lib/stockboy/version.rb +1 -1
- data/spec/spec_helper.rb +5 -2
- data/spec/stockboy/providers/file_spec.rb +5 -4
- data/stockboy.gemspec +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f4c7e5f39621bb22f09bd06f634cb49023d6d6c
|
4
|
+
data.tar.gz: 0bc7683c74a66cc5a9510cde44c2ed15a62a64e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92b3a6d076053c21f48df30fbd544bf2ac952b9fd336a4080466e1b190a632216fc07f59f64756c79238a6304d84fb49e182f1119e6ed1e85376991b4e08cb9d
|
7
|
+
data.tar.gz: cc0a187e65ed56537ca104d23a42a359d064cae1aa6378605d4c60fb4b7c810956a6997f14518f6d710732f8ff4de393be5766bbe3426abad8ca76b985069d16
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
unless ENV["CI"]
|
5
|
+
group :debug do
|
6
|
+
gem "pry"
|
7
|
+
gem "pry-debugger"
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
|
-
group :
|
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
|
data/lib/stockboy/provider.rb
CHANGED
@@ -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 =
|
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
|
data/lib/stockboy/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -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
|
-
|
96
|
+
let(:pick_same) { ->(best, this) { this == target.path ? this : best } }
|
97
97
|
|
98
|
-
|
99
|
-
|
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.
|
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: []
|