bucket_cake 2.0.1 → 3.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 +4 -4
- data/lib/bucket_cake.rb +1 -1
- data/lib/bucket_cake/base.rb +17 -26
- data/lib/bucket_cake/entities.rb +16 -11
- data/lib/bucket_cake/facts.rb +17 -12
- data/lib/bucket_cake/source.rb +15 -31
- data/lib/bucket_cake/values.rb +25 -17
- data/lib/bucket_cake/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c40cb79610b73decea42bbe95851d52ac91b42
|
4
|
+
data.tar.gz: 9cc67aee2afdb05469072c802e7b1ad5acd7e167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2355e18dccb3ddce2f141ae7a0740a5721f12df438dbadcfc7911e1d19ea72e9432985ebc188968a2010ce3f594c5cdb021de933c25e794135fe2bef7287732
|
7
|
+
data.tar.gz: e8fd595e130a1e8d4284b240000941335eb7b65871ee621d5864a19bce5623c014ffe80b154db2aa2f1c4a506f68dbea02cbacc3e9fed63af0b6d23edfe4134f
|
data/lib/bucket_cake.rb
CHANGED
data/lib/bucket_cake/base.rb
CHANGED
@@ -1,39 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BucketCake
|
3
3
|
class Base
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class Range < self
|
5
|
+
def initialize(cursor)
|
6
|
+
raise 'BucketCake: cursor has invalid format!' unless cursor.nil? || cursor =~ CURSOR_REGEXP
|
7
|
+
@cursor = cursor
|
8
|
+
end
|
9
|
+
|
10
|
+
def items
|
11
|
+
get Source::Range.new(self.class::FOLDER, cursor), self.class::PROTOCLASS
|
12
|
+
end
|
7
13
|
end
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def check_cache!
|
14
|
-
return if cache && cache.respond_to?(:read) && cache.respond_to?(:write)
|
15
|
-
|
16
|
-
raise 'BucketCake: cache parameter must respond to #read and #write. ' \
|
17
|
-
'Use Rails.cache if you are not sure.'
|
15
|
+
class Latest < self
|
16
|
+
def items
|
17
|
+
get Source::Latest.new(self.class::FOLDER, nil), self.class::PROTOCLASS
|
18
|
+
end
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
get Source::Latest.new(type, cache), klass
|
22
|
-
end
|
21
|
+
attr_reader :cursor
|
23
22
|
|
24
|
-
|
25
|
-
get Source::Range.new(type, cache), klass
|
26
|
-
end
|
23
|
+
private
|
27
24
|
|
28
25
|
def get(source, klass)
|
29
|
-
|
30
|
-
|
31
|
-
Enumerator.new do |y|
|
32
|
-
Decoder.new(source.zip_files, klass).items.each do |item|
|
33
|
-
y << item
|
34
|
-
end
|
35
|
-
source.confirm!
|
36
|
-
end.lazy
|
26
|
+
@cursor = source.latest_cursor
|
27
|
+
Decoder.new(source.zip_files, klass).items.lazy
|
37
28
|
end
|
38
29
|
end
|
39
30
|
end
|
data/lib/bucket_cake/entities.rb
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BucketCake
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Entities
|
4
|
+
class Advertisers < Base::Latest
|
5
|
+
FOLDER = 'advertisers'
|
6
|
+
PROTOCLASS = Cakeproto::Advertiser
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
class Affiliates < Base::Latest
|
10
|
+
FOLDER = 'affiliates'
|
11
|
+
PROTOCLASS = Cakeproto::Affiliate
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
class Campaigns < Base::Latest
|
15
|
+
FOLDER = 'campaigns'
|
16
|
+
PROTOCLASS = Cakeproto::Campaign
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
class Creatives < Base::Latest
|
20
|
+
FOLDER = 'creatives'
|
21
|
+
PROTOCLASS = Cakeproto::Creative
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
class Offers < Base::Latest
|
25
|
+
FOLDER = 'offers'
|
26
|
+
PROTOCLASS = Cakeproto::Offer
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
data/lib/bucket_cake/facts.rb
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BucketCake
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Facts
|
4
|
+
class Clicks < Base::Range
|
5
|
+
FOLDER = 'clicks'
|
6
|
+
PROTOCLASS = Cakeproto::Click
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
class Conversions < Base::Range
|
10
|
+
FOLDER = 'conversions'
|
11
|
+
PROTOCLASS = Cakeproto::Conversion
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
class ConversionChanges < Base::Range
|
15
|
+
FOLDER = 'conversion_changes'
|
16
|
+
PROTOCLASS = Cakeproto::ConversionChange
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
class CapStates < Base::Range
|
20
|
+
FOLDER = 'cap_states'
|
21
|
+
PROTOCLASS = Cakeproto::CapState
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
class Latest < Base::Latest
|
24
|
+
FOLDER = 'cap_states'
|
25
|
+
PROTOCLASS = Cakeproto::CapState
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
data/lib/bucket_cake/source.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BucketCake
|
3
3
|
class Source
|
4
|
-
def initialize(
|
5
|
-
@
|
6
|
-
@
|
4
|
+
def initialize(folder, cursor)
|
5
|
+
@folder = folder
|
6
|
+
@cursor = cursor
|
7
7
|
end
|
8
8
|
|
9
9
|
def zip_files
|
@@ -22,6 +22,14 @@ module BucketCake
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def latest_cursor
|
26
|
+
@latest_cursor ||= bucket.object("#{folder}/latest").get.body.read
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :folder, :cursor
|
32
|
+
|
25
33
|
def check_success(key)
|
26
34
|
@success_files ||= Set.new
|
27
35
|
@success_files << key if key.end_with?('/SUCCESS')
|
@@ -31,30 +39,6 @@ module BucketCake
|
|
31
39
|
@success_files.include?(File.dirname(key) + '/SUCCESS')
|
32
40
|
end
|
33
41
|
|
34
|
-
def new_data?
|
35
|
-
current_latest_path != cache_latest_path
|
36
|
-
end
|
37
|
-
|
38
|
-
def confirm!
|
39
|
-
cache.write(cache_key, current_latest_path)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
attr_reader :type, :cache
|
45
|
-
|
46
|
-
def cache_key
|
47
|
-
"#{CACHE_PREFIX}-#{type}"
|
48
|
-
end
|
49
|
-
|
50
|
-
def current_latest_path
|
51
|
-
@current_latest_path ||= bucket.object("#{type}/latest").get.body.read
|
52
|
-
end
|
53
|
-
|
54
|
-
def cache_latest_path
|
55
|
-
@cache_latest_path ||= cache.read(cache_key)
|
56
|
-
end
|
57
|
-
|
58
42
|
def bucket
|
59
43
|
@bucket ||= Aws::S3::Bucket.new(ENV.fetch('CAKE_DATA_BUCKET'))
|
60
44
|
end
|
@@ -64,7 +48,7 @@ module BucketCake
|
|
64
48
|
private
|
65
49
|
|
66
50
|
def objects
|
67
|
-
bucket.objects(prefix: "#{
|
51
|
+
bucket.objects(prefix: "#{folder}/#{latest_cursor}/")
|
68
52
|
end
|
69
53
|
end
|
70
54
|
|
@@ -72,13 +56,13 @@ module BucketCake
|
|
72
56
|
private
|
73
57
|
|
74
58
|
def objects
|
75
|
-
# If we don't have a timestamp in
|
76
|
-
return bucket.objects(prefix: "#{
|
59
|
+
# If we don't have a timestamp in cursor, return everything
|
60
|
+
return bucket.objects(prefix: "#{folder}/") if cursor.nil?
|
77
61
|
|
78
62
|
# This returns all objects after the current timestamp.
|
79
63
|
# By using the 'xxx' suffix, none of the objects of the given timestamp are returned.
|
80
64
|
# S3 ensures alphabetical order of the results, so this works fine for date ranges.
|
81
|
-
bucket.objects(marker: "#{
|
65
|
+
bucket.objects(marker: "#{folder}/#{cursor}/xxx", prefix: "#{folder}/")
|
82
66
|
end
|
83
67
|
end
|
84
68
|
end
|
data/lib/bucket_cake/values.rb
CHANGED
@@ -1,36 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BucketCake
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Values
|
4
|
+
class AffiliateTiers < Base::Latest
|
5
|
+
FOLDER = 'affiliate_tiers'
|
6
|
+
PROTOCLASS = Cakeproto::IdName
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
class BlacklistReasons < Base::Latest
|
10
|
+
FOLDER = 'blacklist_reasons'
|
11
|
+
PROTOCLASS = Cakeproto::IdName
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
class Countries < Base::Latest
|
15
|
+
FOLDER = 'countries'
|
16
|
+
PROTOCLASS = Cakeproto::Country
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
class Currencies < Base::Latest
|
20
|
+
FOLDER = 'currencies'
|
21
|
+
PROTOCLASS = Cakeproto::Currency
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
class ExchangeRates < Base::Latest
|
25
|
+
FOLDER = 'exchange_rates'
|
26
|
+
PROTOCLASS = Cakeproto::ExchangeRate
|
22
27
|
end
|
23
28
|
|
24
|
-
|
25
|
-
|
29
|
+
class MediaTypes < Base::Latest
|
30
|
+
FOLDER = 'media_types'
|
31
|
+
PROTOCLASS = Cakeproto::IdName
|
26
32
|
end
|
27
33
|
|
28
|
-
|
29
|
-
|
34
|
+
class PaymentTypes < Base::Latest
|
35
|
+
FOLDER = 'payment_types'
|
36
|
+
PROTOCLASS = Cakeproto::IdName
|
30
37
|
end
|
31
38
|
|
32
|
-
|
33
|
-
|
39
|
+
class Verticals < Base::Latest
|
40
|
+
FOLDER = 'verticals'
|
41
|
+
PROTOCLASS = Cakeproto::IdName
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
data/lib/bucket_cake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucket_cake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activesupport
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: bundler
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
196
|
version: '0'
|
211
197
|
requirements: []
|
212
198
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.6.4
|
214
200
|
signing_key:
|
215
201
|
specification_version: 4
|
216
202
|
summary: Get cakeproto objects from S3.
|