eucalyptus 0.2.13 → 0.3.0

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: 0928d347709d4f059acdb3fff1259337dca47b1a
4
- data.tar.gz: ce0cfa1f5d9f6a2c28fb1b37174a07e6d8393c9d
3
+ metadata.gz: 6663e651eea1190e5c8c6dd3466fa809b5cf437d
4
+ data.tar.gz: b7e3e205eea38a8d15fda0ed023051a4344bc490
5
5
  SHA512:
6
- metadata.gz: 72c2f01af338629dbc2cbeb4e7e8d77d4a2ddc686bc9d7a35ec94922b3a1e00823fa35033fd348e0c8c37ce9fc3e233d42d464da223896124a885a3d4721aea0
7
- data.tar.gz: 7791aa8ec3f0b226f836c02ea9db3ebafbe3766ce5ac8db952b7ee8d09098a7921ba11a00b8f674528f2d8dc48d47efc50bd39f46ed196a8aec8a28a4668f907
6
+ metadata.gz: 344b74cbc6821359b40d825dea713a1c4b5078d91c6814030839900327b9f9f6135fa08f583caf854cdf46c93181ccfbb74dcc6ff6dd92fed52d080f91c4cda7
7
+ data.tar.gz: 2d1d55eb1a857703ca4552cd9e1b6bed3be5c13cb0ee008855c82c0d75134c62e7e5831d7a32471debcc77373c6d816b7bfa73beaae9157222caf2d74f66614b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.13
1
+ 0.3.0
data/eucalyptus.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: eucalyptus 0.2.13 ruby lib
5
+ # stub: eucalyptus 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "eucalyptus"
9
- s.version = "0.2.13"
9
+ s.version = "0.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Oguz Huner"]
14
- s.date = "2015-07-08"
14
+ s.date = "2015-08-04"
15
15
  s.description = "An easy interface and abstraction to the Facebook Ads API"
16
16
  s.email = "oguzcanhuner@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -3,34 +3,7 @@ require_relative 'resource'
3
3
  module Eucalyptus
4
4
  class Insight < Resource
5
5
  def self.known_fields
6
- [
7
- :call_to_action_clicks,
8
- :clicks,
9
- :unique_clicks,
10
- :cost_per_total_action,
11
- :cpc,
12
- :cost_per_unique_click,
13
- :cpm,
14
- :cpp,
15
- :ctr,
16
- :website_ctr,
17
- :unique_ctr,
18
- :frequency,
19
- :impressions,
20
- :reach,
21
- :relevance_score,
22
- :social_clicks,
23
- :unique_social_clicks,
24
- :social_impressions,
25
- :social_reach,
26
- :spend,
27
- :total_action_value,
28
- :total_actions,
29
- :total_unique_actions,
30
- :cost_per_action_type,
31
- :action_values,
32
- :actions
33
- ]
6
+ nil
34
7
  end
35
8
 
36
9
  def self.find
@@ -1,6 +1,8 @@
1
1
  require 'json'
2
2
 
3
+
3
4
  module Eucalyptus
5
+
4
6
  class Resource
5
7
  def self.api_path
6
8
  raise "You must implement #{__method__.to_s}"
@@ -28,8 +30,8 @@ module Eucalyptus
28
30
  options[:fields] = self.known_fields
29
31
  end
30
32
 
31
- response = graph.get_connection(parent.id, api_path, options)
32
- response.collect{ |res| self.new(res) }
33
+ koala_response = graph.get_connection(parent.id, api_path, options)
34
+ ResponseCollection.new(self, koala_response)
33
35
  end
34
36
 
35
37
 
@@ -70,3 +72,4 @@ module Eucalyptus
70
72
  end
71
73
  end
72
74
  end
75
+
@@ -13,4 +13,28 @@ module Eucalyptus
13
13
  end
14
14
  end
15
15
  end
16
+
17
+ class ResponseCollection
18
+ def initialize(klass, koala_response)
19
+ @koala_response = koala_response
20
+ @klass = klass
21
+ @array = elements(@koala_response)
22
+ end
23
+
24
+
25
+ def next_page
26
+ next_page = @koala_response.next_page
27
+ self.class.new(@klass, next_page)
28
+ end
29
+
30
+ # for array methods
31
+ def method_missing(method_sym, *args, &block)
32
+ @array.send(method_sym)
33
+ end
34
+
35
+ private
36
+ def elements(response)
37
+ response.collect{ |res| @klass.new(res) }
38
+ end
39
+ end
16
40
  end
@@ -12,7 +12,7 @@ describe Eucalyptus::Account do
12
12
  describe '#insights' do
13
13
  it 'returns an array of insights for the account' do
14
14
  VCR.use_cassette("account_insights") do
15
- expect(account.insights).to be_a Array
15
+ expect(account.insights).to be_a Eucalyptus::ResponseCollection
16
16
  expect(account.insights.first).to be_a Eucalyptus::Insight
17
17
  end
18
18
  end
@@ -21,7 +21,7 @@ describe Eucalyptus::Account do
21
21
  describe '#ads' do
22
22
  it 'returns a collection of Ad objects which belong to the account' do
23
23
  VCR.use_cassette("account_ads") do
24
- expect(account.ads).to be_a Array
24
+ expect(account.ads).to be_a Eucalyptus::ResponseCollection
25
25
  expect(account.ads.first).to be_a Eucalyptus::Ad
26
26
  end
27
27
  end
@@ -30,7 +30,7 @@ describe Eucalyptus::Account do
30
30
  describe '#ad_sets' do
31
31
  it 'returns a collection of AdSet objects which belong to the account' do
32
32
  VCR.use_cassette("account_ad_sets") do
33
- expect(account.ad_sets).to be_a Array
33
+ expect(account.ad_sets).to be_a Eucalyptus::ResponseCollection
34
34
  expect(account.ad_sets.first).to be_a Eucalyptus::AdSet
35
35
  end
36
36
  end
@@ -39,7 +39,7 @@ describe Eucalyptus::Account do
39
39
  describe '#campaigns' do
40
40
  it 'returns a collection of Campaign objects which belong to the account' do
41
41
  VCR.use_cassette("account_campaigns") do
42
- expect(account.campaigns).to be_a Array
42
+ expect(account.campaigns).to be_a Eucalyptus::ResponseCollection
43
43
  expect(account.campaigns.first).to be_a Eucalyptus::Campaign
44
44
  end
45
45
  end
@@ -12,8 +12,7 @@ describe Eucalyptus::AdSet do
12
12
  describe '#insights' do
13
13
  it 'returns an array of insights for the account' do
14
14
  VCR.use_cassette("ad_set_insights") do
15
- active_ad_set = Eucalyptus::AdSet.all.find{|ad_set| ad_set.campaign_status == "ACTIVE"}
16
- expect(active_ad_set.insights).to be_a Array
15
+ active_ad_set = Eucalyptus::AdSet.all.find{|ad_set| ad_set.campaign_status == "ACTIVE"}.first
17
16
  expect(active_ad_set.insights.first).to be_a Eucalyptus::Insight
18
17
  end
19
18
  end
@@ -30,7 +29,6 @@ describe Eucalyptus::AdSet do
30
29
  describe '#ads' do
31
30
  it 'returns a collection of Ad objects which belong to the ad_set' do
32
31
  VCR.use_cassette("ad_set_ads") do
33
- expect(ad_set.ads).to be_a Array
34
32
  expect(ad_set.ads.first).to be_a Eucalyptus::Ad
35
33
  end
36
34
  end
@@ -21,8 +21,7 @@ describe Eucalyptus::Ad do
21
21
  describe '#insights' do
22
22
  it 'returns an array of insights for the account' do
23
23
  VCR.use_cassette("ad_set_insights") do
24
- active_ad = Eucalyptus::Ad.all.find{|ad| ad.adgroup_status == "ACTIVE"}
25
- expect(active_ad.insights).to be_a Array
24
+ active_ad = Eucalyptus::Ad.all.find{|ad| ad.adgroup_status == "ACTIVE"}.first
26
25
  expect(active_ad.insights.first).to be_a Eucalyptus::Insight
27
26
  end
28
27
  end
@@ -12,7 +12,6 @@ describe Eucalyptus::Campaign do
12
12
  describe '#insights' do
13
13
  it 'returns an array of insights for the account' do
14
14
  VCR.use_cassette("campaign_insights") do
15
- expect(campaign.insights).to be_a Array
16
15
  expect(campaign.insights.first).to be_a Eucalyptus::Insight
17
16
  end
18
17
  end
@@ -21,7 +20,6 @@ describe Eucalyptus::Campaign do
21
20
  describe '#ads' do
22
21
  it 'returns a collection of Ad objects which belong to the campaign' do
23
22
  VCR.use_cassette("campaign_ads") do
24
- expect(campaign.ads).to be_a Array
25
23
  expect(campaign.ads.first).to be_a Eucalyptus::Ad
26
24
  end
27
25
  end
@@ -30,7 +28,6 @@ describe Eucalyptus::Campaign do
30
28
  describe '#ad_sets' do
31
29
  it 'returns a collection of Ad objects which belong to the campaign' do
32
30
  VCR.use_cassette("campaign_ad_sets") do
33
- expect(campaign.ad_sets).to be_a Array
34
31
  expect(campaign.ad_sets.first).to be_a Eucalyptus::AdSet
35
32
  end
36
33
  end
@@ -57,7 +57,7 @@ describe Eucalyptus::Resource do
57
57
  let(:parent) { double(:parent, id: 123) }
58
58
 
59
59
  it 'returns a collection of resources' do
60
- expect(Eucalyptus::CustomAudience.all(graph: graph, parent: parent)).to be_a Array
60
+ expect(Eucalyptus::CustomAudience.all(graph: graph, parent: parent)).to be_a Eucalyptus::ResponseCollection
61
61
  end
62
62
 
63
63
  context 'when the target class has defined valid known fields' do
@@ -109,6 +109,16 @@ describe Eucalyptus::Resource do
109
109
  end
110
110
  end
111
111
 
112
+ describe '#next_page' do
113
+ it 'updates a resource' do
114
+ VCR.use_cassette("adsets_next") do
115
+ ad_sets = Eucalyptus::AdSet.all
116
+ expect(ad_sets.next_page).to be_a Eucalyptus::ResponseCollection
117
+ expect(ad_sets.next_page.first).to be_a Eucalyptus::AdSet
118
+ end
119
+ end
120
+ end
121
+
112
122
  describe '#method_missing' do
113
123
  let(:response) { { "id" => "123", "name" => "Audience", "stats" => {"cpa" => "12"} }}
114
124
  let(:resource) { Eucalyptus::CustomAudience.new(response) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eucalyptus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oguz Huner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: koala