opera-mobile-store-sdk 0.1.3 → 0.1.4

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: ea561cac052e9ae2e85a5b497683918571d0bb38
4
- data.tar.gz: 428415aef7a5e9bdd17fd67678ac0c813bdfa33e
3
+ metadata.gz: caf7ab8aee315eb11bf1591e3ebcfe0b7658ab4e
4
+ data.tar.gz: 338a216c2d284cd812646005592a59777f09b8eb
5
5
  SHA512:
6
- metadata.gz: 3d1bf6eb12b9869995f71a43ff69f93a0ba1796c9e5345620d7066a97f1add2d804201c51613ac307a8f324109cceeb056640f5c51b0ced775a25b57843be611
7
- data.tar.gz: c490eca79640c9cac48c58141980fe03d2c28b8f82b4fd4445506dfcfc0f06ef1938c61eb1b321cb19eddd4bb33be443eeadaa923c9d0effdae796a036cced14
6
+ metadata.gz: 8a55570d35892d7d23d86cb4c98c5016764123920b48dc05b378bd3e1bb1bbee1262a0a75e8e1e65dc604889a6485a723f9ffa4b1946717fafa7d180c161fc70
7
+ data.tar.gz: 48783119a2fb7abaf69a80a4ea2bcd1d525e342f22139ad379bf5cf8d992824c783b12d3ceb87f813e2ca849a71812a21126f63440116ab5ec6bd2fbabe5861f
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  .ruby-version
11
11
  /opera-mobile-store-sdk-*.gem
12
+ /*.env
@@ -1,5 +1,5 @@
1
1
  module Opera
2
2
  module MobileStoreSDK
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ module Opera
2
+ module AdMarvel
3
+ class Click
4
+
5
+ include Opera::AdMarvel::Reportable
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ require 'securerandom'
2
+
3
+ module Opera
4
+ module AdMarvel
5
+ class Impression
6
+
7
+ include Opera::AdMarvel::Reportable
8
+
9
+ attr_accessor :random, :user_id
10
+
11
+ def random
12
+ @random ||= SecureRandom.random_number(18446744073709551615)
13
+ end
14
+
15
+ # Override to add random and user_id:
16
+ def attributes_with_payload_keys
17
+ super.merge(
18
+ { "cb" => random, "uid" => user_id }.select { |_, value| !value.nil? }
19
+ )
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,52 @@
1
+ module Opera
2
+ module AdMarvel
3
+
4
+ module Reportable
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ include ActiveModel::Model
10
+ include ActiveModel::Serialization
11
+
12
+ attr_accessor :partner_id, :site_id, :banner_id
13
+ end
14
+
15
+ def attributes_with_payload_keys
16
+ {
17
+ "pid" => partner_id, "sid" => site_id, "bid" => banner_id
18
+ }.select { |_, value| !value.nil? }
19
+ end
20
+
21
+ def as_payload
22
+ attributes_with_payload_keys.inject("") do |payload, keyval|
23
+ "#{payload}__#{keyval.join('=')}"
24
+ end
25
+ end
26
+
27
+ def save
28
+ unless @already_saved
29
+
30
+ collector_path = "/fam/" + case self.class.name.demodulize
31
+ when "Impression" then "view_offline.php"
32
+ when "Click" then "ck_offline.php"
33
+ else raise "Not Implemented"
34
+ end
35
+
36
+ @already_saved = true
37
+ end
38
+ end
39
+
40
+ module ClassMethods
41
+ def create(given_attributes = {})
42
+ reportable = self.new given_attributes
43
+ reportable.save
44
+ reportable
45
+ end
46
+ alias_method :report, :create
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,39 @@
1
+ module Opera
2
+ module AdMarvelSDK
3
+ class Config
4
+
5
+ include ActiveSupport::Configurable
6
+
7
+ DEFAULT_API_URL = "http://ads.admarvel.com".freeze
8
+
9
+ # API host:
10
+ config_accessor :api_host do
11
+ api_uri = URI(ENV.fetch "OPERA_AD_MARVEL_API_URL", DEFAULT_API_URL)
12
+ api_uri.path = ""
13
+ api_uri.to_s
14
+ end
15
+
16
+ # API path:
17
+ config_accessor :api_path do
18
+ api_uri = URI(ENV.fetch "OPERA_AD_MARVEL_API_URL", DEFAULT_API_URL)
19
+ api_uri.path
20
+ end
21
+
22
+ # API Call Timeout:
23
+ config_accessor :api_call_timeout do
24
+ ENV.fetch("OPERA_AD_MARVEL_API_CALL_TIMEOUT", 15).to_i
25
+ end
26
+
27
+ # API Call Open Timeout:
28
+ config_accessor :api_call_open_timeout do
29
+ ENV.fetch("OPERA_AD_MARVEL_API_CALL_OPEN_TIMEOUT", 2).to_i
30
+ end
31
+
32
+ # Logger:
33
+ config_accessor :logger do
34
+ Logger.new($stdout)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -128,20 +128,24 @@ module Opera::MobileStore
128
128
  def self.build_from_nokogiri_node(node)
129
129
 
130
130
  # Initialize the category unless it's already in it's Identity Map:
131
- category_id = node.xpath("number(category/@id)").to_i
131
+ category_id = if (some_id = node.xpath 'number(category/@id)') && !some_id.nan?
132
+ some_id.to_i
133
+ end
134
+
132
135
  Category.new(
133
136
  id: category_id,
134
137
  code: node.xpath("string(category/@code)"),
135
138
  name: node.xpath("string(category)")
136
- ) unless Category.identity_mapped? category_id
139
+ ) unless category_id.blank? || Category.identity_mapped?(category_id)
137
140
 
138
141
  # Initialize the category unless it's already in it's Identity Map:
139
- author_id = node.xpath("number(author/@id)").to_i
142
+ author_id = node.xpath 'number(author/@id)').to_i
143
+
140
144
  Developer.new(
141
145
  id: author_id,
142
146
  name: node.xpath("string(author)"),
143
147
  email: node.xpath("string(author_email)")
144
- ) unless Developer.identity_mapped? author_id
148
+ ) unless author_id.blank? || Developer.identity_mapped?(author_id)
145
149
 
146
150
  data = {
147
151
  id: node.xpath("number(@id)").to_i,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera-mobile-store-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Quintanilla
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -127,6 +127,12 @@ files:
127
127
  - bin/setup
128
128
  - lib/opera-mobile-store-sdk.rb
129
129
  - lib/opera-mobile-store-sdk/version.rb
130
+ - lib/opera/ad_marvel/models/ad.rb
131
+ - lib/opera/ad_marvel/models/campaign.rb
132
+ - lib/opera/ad_marvel/models/click.rb
133
+ - lib/opera/ad_marvel/models/impression.rb
134
+ - lib/opera/ad_marvel/models/reportable.rb
135
+ - lib/opera/ad_marvel/sdk/config.rb
130
136
  - lib/opera/mobile_store/build.rb
131
137
  - lib/opera/mobile_store/build_file.rb
132
138
  - lib/opera/mobile_store/category.rb