adriver_api 0.0.3 → 0.0.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: 609194bdf53a66db0319cc8b22f5766703e12f07
4
- data.tar.gz: db96ee6d762e97fa30dfbd3bb8a9bc8762ce6307
3
+ metadata.gz: 7b19de168b6ade8ae3b5210a63651117cc56d657
4
+ data.tar.gz: 88c99c9e681b1b5f81e90d33f94fde67907e420e
5
5
  SHA512:
6
- metadata.gz: e03c5a24fea00d91f1d24c65de64ce19365f51a2eb91a88c073ccf420579c8b1874b7fa367ce9c426fd2c93b15f577fabebb267bc4e46d61ea6429933a929d9d
7
- data.tar.gz: ccd011a4218bd3d817469594fe14efc22ac4b4097a32a0420eb5d94688076e186cbb01a25b72f988ca02a4628bc001df390e713014befa81a6c82321c46b2b07
6
+ metadata.gz: d2a01edb7257d049b01e730de2d93822f58c1eb37ee67dba94120328aba2e4fcd88c0b6276ae2ab55b9cd7235bd025315e135d5fee1d6f662aa6078e0585848e
7
+ data.tar.gz: da9c25c5e897affd57262de87bc6535565ee2d17cfd30e91fa9ec48fe9cc3facce483672d9737144c1362e9c8b98aa146f96bd102ded234b953b95d0853a1cf4
@@ -14,7 +14,7 @@ module AdriverApi
14
14
  def ads_delegated(raw: false)
15
15
  response = make_request('ads/delegated', user_id: @user_id.to_s)
16
16
  return response if raw
17
- Array(response.body['feed']['entry']).map{|x| x['id'].split('/').last}
17
+ Array.wrap(response.body['feed']['entry']).map{|x| x['id'].split('/').last}
18
18
  end
19
19
 
20
20
  # Info about ad
@@ -25,7 +25,7 @@ module AdriverApi
25
25
  h[:id] = response.body['entry']['content']['ad']['id']
26
26
  h[:name] = response.body['entry']['content']['ad']['name']
27
27
  h[:enable] = response.body['entry']['content']['ad']['enable']
28
- h[:adplacements] = Array(response.body['entry']['content']['ad']['adPlacements']['href']).map{|x| x.split('/').last}
28
+ h[:adplacements] = Array.wrap(response.body['entry']['content']['ad']['adPlacements']['href']).map{|x| x.split('/').last}
29
29
  h
30
30
  end
31
31
 
@@ -34,7 +34,7 @@ module AdriverApi
34
34
  response = make_request('adplacements', ad_id: ad_id)
35
35
  return response if raw
36
36
  #TODO: иногда массив, иногда строка
37
- Array(response.body['feed']['entry']).map{|x| {id: x['content']['adPlacement']['id'], name: x['content']['adPlacement']['name'], banners: x['content']['adPlacement']['banners'] ? Array(x['content']['adPlacement']['banners']['href']).map{|x2| x2.split('/').last} : []} }
37
+ Array.wrap(response.body['feed']['entry']).map{|x| {id: x['content']['adPlacement']['id'], name: x['content']['adPlacement']['name'], banners: x['content']['adPlacement']['banners'] ? Array.wrap(x['content']['adPlacement']['banners']['href']).map{|x2| x2.split('/').last} : []} }
38
38
  end
39
39
 
40
40
  def banner(ban_id)
@@ -45,7 +45,7 @@ module AdriverApi
45
45
  response = make_request("stat/banners/#{ban_id}", start_date: start_date, stop_date: stop_date, granularity: period)
46
46
  return response if raw
47
47
  h = {}
48
- Array(response.body['entry']['content']['statObject']['stat']['item']).each{|x| h[x['date']] = {views: x['exp'], clicks: x['click']} }
48
+ Array.wrap(response.body['entry']['content']['statObject']['stat']['item']).each{|x| h[x['date']] = {views: x['exp'], clicks: x['click']} }
49
49
  h
50
50
  end
51
51
 
@@ -1,3 +1,3 @@
1
1
  module AdriverApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/adriver_api.rb CHANGED
@@ -12,3 +12,14 @@ module AdriverApi
12
12
 
13
13
  end
14
14
  end
15
+
16
+
17
+ def Array.wrap(object)
18
+ if object.nil?
19
+ []
20
+ elsif object.respond_to?(:to_ary)
21
+ object.to_ary || [object]
22
+ else
23
+ [object]
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adriver_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Yudin