beso 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/beso/version.rb +1 -1
  2. data/lib/tasks/beso.rake +57 -0
  3. metadata +2 -1
data/lib/beso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Beso
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,57 @@
1
+ namespace :beso do
2
+
3
+ desc "Run Beso jobs and upload to S3"
4
+ task :run => :environment do
5
+
6
+ raise 'Beso has no jobs to run. Please define some in the beso initializer.' if Beso.jobs.empty?
7
+
8
+ puts '==> Connecting...'
9
+
10
+ Beso.connect do |bucket|
11
+
12
+ puts '==> Connected!'
13
+
14
+ prefix = ENV[ 'BESO_PREFIX' ] || 'beso'
15
+ config = YAML.load( bucket.read 'beso.yml' ) || { }
16
+
17
+ puts '==> Config:'
18
+ puts config.inspect
19
+
20
+ Beso.jobs.each do |job|
21
+
22
+ config[ job.event ] ||= begin
23
+ case ENV[ 'BESO_ORIGIN' ]
24
+ when 'first'
25
+ job.first_timestamp
26
+ when 'now'
27
+ Time.now
28
+ else
29
+ job.last_timestamp
30
+ end
31
+ end
32
+
33
+ puts "==> Processing job: #{job.event.inspect} since #{config[ job.event ]}"
34
+
35
+ csv = job.to_csv :since => config[ job.event ]
36
+
37
+ if csv
38
+ filename = "#{prefix}-#{job.event}-#{config[ job.event ].to_i}.csv"
39
+
40
+ bucket.write filename, csv
41
+
42
+ puts " ==> #{filename} saved to S3"
43
+
44
+ config[ job.event ] = job.last_timestamp
45
+
46
+ puts " ==> New timestamp is #{config[ job.event ]}"
47
+ else
48
+ puts " ==> No records found since #{config[ job.event ]}. Skipping..."
49
+ end
50
+ end
51
+
52
+ bucket.write 'beso.yml', config.to_yaml
53
+
54
+ puts '==> Config saved. Donezo.'
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -121,6 +121,7 @@ files:
121
121
  - lib/beso/job.rb
122
122
  - lib/beso/railtie.rb
123
123
  - lib/beso/version.rb
124
+ - lib/tasks/beso.rake
124
125
  - spec/beso/aws_spec.rb
125
126
  - spec/beso/config_spec.rb
126
127
  - spec/beso/job_spec.rb