fb_graph2 0.6.2 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f256941ae5f6e57c032e79b72181a0f0559f81d4
4
- data.tar.gz: cd9680ddc658ed74be3edb23a58ec8e3b1d937b8
3
+ metadata.gz: 69aa898f673a4c9523dcf9fadac98ee3dfa58d93
4
+ data.tar.gz: 2603a36423178448607d3a5f90a6af7aaa108fbc
5
5
  SHA512:
6
- metadata.gz: 77007d17c1fa5a86873d946f5bb9c6be5510234da913427279de16b88642df3302997e8821c5ab8ffa11d101d1fe6e4c74909927c002450cc8d5731e5592d806
7
- data.tar.gz: 529f93e41ac150f713452bee3d86a89409860b44430da35e7115591768085945f778125241095963899a8dab6e24d6c838a61891ec097ff3a9dde3bd7ce72ae8
6
+ metadata.gz: ab1a1cca08967be7cebdb895ab44dbc2267a702d1205506563a359ba3591f6f992358635cf83de2935494fecde356fec75125eaa27e20811f54387fb209121ac
7
+ data.tar.gz: 77d801e80f7bea3ba9e7b1cc7631652808a48b8e55358a5b01559bf89f3c319f8a4f4faf92053ce574e8bd2f955a51fbbc741ce6d29a7f778056009e3d0b6802
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.7.0
@@ -12,6 +12,9 @@ module FbGraph2
12
12
  self.send :"#{link_attr}=", collect_links(attributes, link_attr)
13
13
  end
14
14
  end
15
+ if attributes.include? :web
16
+ self.web = Struct::AppLink::Web.new attributes[:web]
17
+ end
15
18
  end
16
19
 
17
20
  private
@@ -5,14 +5,26 @@ module FbGraph2
5
5
  included do
6
6
  extend ClassMethods
7
7
  attr_accessor :raw_attributes
8
- cattr_accessor :registered_attributes
9
8
  end
10
9
 
11
10
  module ClassMethods
12
11
  def register_attributes(attributes)
13
- self.registered_attributes = attributes
12
+ @registered_attributes ||= {}
13
+ attributes.each do |type, keys|
14
+ @registered_attributes[type] ||= []
15
+ @registered_attributes[type] += keys
16
+ end
14
17
  send :attr_accessor, *attributes.values.flatten
15
18
  end
19
+
20
+ def registered_attributes
21
+ @registered_attributes
22
+ end
23
+
24
+ def inherited(child)
25
+ super
26
+ child.register_attributes registered_attributes
27
+ end
16
28
  end
17
29
 
18
30
  def assign(attributes)
@@ -4,9 +4,23 @@ module FbGraph2
4
4
  def app_link_hosts(params = {})
5
5
  hosts = self.edge :app_link_hosts, params
6
6
  hosts.collect! do |host|
7
- AppLinkHost.new(hosts[:id], hosts).authenticate self.access_token
7
+ AppLinkHost.new(host[:id], host).authenticate self.access_token
8
8
  end
9
9
  end
10
+
11
+ def app_link_host!(params = {})
12
+ jsonized_params = params.inject({}) do |jsonized_params, (key, value)|
13
+ jsonized_param = case value
14
+ when Hash, Array
15
+ value.to_json
16
+ else
17
+ value
18
+ end
19
+ jsonized_params.merge! key => jsonized_param
20
+ end
21
+ host = self.post jsonized_params, edge: :app_link_hosts
22
+ AppLinkHost.new(host[:id], params.merge(host)).authenticate self.access_token
23
+ end
10
24
  end
11
25
  end
12
26
  end
@@ -18,13 +18,21 @@ module FbGraph2
18
18
 
19
19
  class Android < Native
20
20
  register_attributes(
21
- raw: [:class, :package]
21
+ raw: [:package],
22
+ custom: [:klass]
22
23
  )
24
+
25
+ def initialize(attributes = {})
26
+ super
27
+ if attributes.include? :class
28
+ self.klass = attributes[:class]
29
+ end
30
+ end
23
31
  end
24
32
 
25
33
  class WindowsPhone < Native
26
34
  register_attributes(
27
- raw: [:app_name]
35
+ raw: [:app_id]
28
36
  )
29
37
  end
30
38
  end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::AppLinkHost do
4
+ let(:app_link_host) do
5
+ FbGraph2::AppLinkHost.new(
6
+ 'host_id',
7
+ name: 'Sample',
8
+ canonical_url: 'https://fb.me/804327549686491',
9
+ ios: [{
10
+ app_name: 'Sample iOS',
11
+ app_store_id: 'ios.sample.fb_graph2',
12
+ url: 'fbgraph2://ios'
13
+ }],
14
+ iphone: [{
15
+ app_name: 'Sample iPhone',
16
+ app_store_id: 'iphone.sample.fb_graph2',
17
+ url: 'fbgraph2://iphone'
18
+ }],
19
+ android: [{
20
+ app_name: 'Sample Android',
21
+ class: 'FbGraph2',
22
+ package: 'android.sample.fb_graph2',
23
+ url: 'fbgraph2://android'
24
+ }],
25
+ windows_phone: [{
26
+ app_name: 'Sample WindowsPhone',
27
+ app_id: 'windows_phone.sample.fb_graph2',
28
+ url: 'fbgraph2://windows_phone'
29
+ }],
30
+ web: {
31
+ should_fallback: true,
32
+ url: 'https://fbgraphsample.herokuapp.com/app_links/sample'
33
+ }
34
+ )
35
+ end
36
+ subject { app_link_host }
37
+
38
+ its(:id) { should == 'host_id' }
39
+ its(:name) { should == 'Sample' }
40
+ its(:canonical_url) { should == 'https://fb.me/804327549686491' }
41
+
42
+ describe 'iOS' do
43
+ subject { app_link_host.ios.first }
44
+ its(:app_name) { should == 'Sample iOS' }
45
+ its(:app_store_id) { should == 'ios.sample.fb_graph2' }
46
+ its(:url) { should == 'fbgraph2://ios' }
47
+ end
48
+
49
+ describe 'iPhone' do
50
+ subject { app_link_host.iphone.first }
51
+ its(:app_name) { should == 'Sample iPhone' }
52
+ its(:app_store_id) { should == 'iphone.sample.fb_graph2' }
53
+ its(:url) { should == 'fbgraph2://iphone' }
54
+ end
55
+
56
+ describe 'Android' do
57
+ subject { app_link_host.android.first }
58
+ its(:app_name) { should == 'Sample Android' }
59
+ its(:klass) { should == 'FbGraph2' }
60
+ its(:package) { should == 'android.sample.fb_graph2' }
61
+ its(:url) { should == 'fbgraph2://android' }
62
+ end
63
+
64
+ describe 'WindowsPhone' do
65
+ subject { app_link_host.windows_phone.first }
66
+ its(:app_name) { should == 'Sample WindowsPhone' }
67
+ its(:app_id) { should == 'windows_phone.sample.fb_graph2' }
68
+ its(:url) { should == 'fbgraph2://windows_phone' }
69
+ end
70
+ end
@@ -5,13 +5,13 @@ describe FbGraph2::Edge::Achievements do
5
5
  describe '#achievements' do
6
6
  let(:me) { FbGraph2::User.me('token') }
7
7
  it 'should return an Array of FbGraph2::Achievement' do
8
- pages = mock_graph :get, 'me/achievements', 'user/achievements', access_token: 'token' do
8
+ achievements = mock_graph :get, 'me/achievements', 'user/achievements', access_token: 'token' do
9
9
  me.achievements
10
10
  end
11
- pages.should be_instance_of FbGraph2::Edge
12
- pages.should_not be_blank
13
- pages.each do |page|
14
- page.should be_instance_of FbGraph2::Achievement
11
+ achievements.should be_instance_of FbGraph2::Edge
12
+ achievements.should_not be_blank
13
+ achievements.each do |achievement|
14
+ achievement.should be_instance_of FbGraph2::Achievement
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::Edge::AppLinkHosts do
4
+ let(:app) { FbGraph2::App.app('app_token') }
5
+
6
+ describe '#app_link_hosts' do
7
+ it 'should return an Array of FbGraph2::AppLinkHost' do
8
+ mock_graph :get, 'app/app_link_hosts', 'app/app_link_hosts', access_token: 'app_token' do
9
+ hosts = app.app_link_hosts
10
+ hosts.should be_instance_of FbGraph2::Edge
11
+ hosts.should_not be_blank
12
+ hosts.each do |host|
13
+ host.should be_instance_of FbGraph2::AppLinkHost
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ describe '#app_link_host!' do
20
+ it 'should return an FbGraph2::AppLinkHost' do
21
+ mock_graph :post, 'app/app_link_hosts', 'success_with_id', access_token: 'app_token', params: {
22
+ name: 'Sample',
23
+ web: {
24
+ should_fallback: true,
25
+ url: 'https://fbgraphsample.herokuapp.com/app_links/sample'
26
+ }.to_json,
27
+ windows_phone: [{
28
+ url: 'test://activate'
29
+ }].to_json
30
+ } do
31
+ host = app.app_link_host!(
32
+ name: 'Sample',
33
+ web: {
34
+ should_fallback: true,
35
+ url: 'https://fbgraphsample.herokuapp.com/app_links/sample'
36
+ },
37
+ windows_phone: [{
38
+ url: 'test://activate'
39
+ }]
40
+ )
41
+ host.should be_instance_of FbGraph2::AppLinkHost
42
+ host.id.should == 'created_object_id'
43
+ host.name.should == 'Sample'
44
+ host.web.should be_instance_of FbGraph2::Struct::AppLink::Web
45
+ host.web.should_fallback.should == true
46
+ host.web.url.should == 'https://fbgraphsample.herokuapp.com/app_links/sample'
47
+ host.windows_phone.should be_instance_of FbGraph2::Collection
48
+ host.windows_phone.each do |link|
49
+ link.should be_instance_of FbGraph2::Struct::AppLink::Native::WindowsPhone
50
+ end
51
+ host.windows_phone.first.url.should == 'test://activate'
52
+ end
53
+ end
54
+ end
55
+ end
@@ -60,7 +60,6 @@ describe FbGraph2::Node do
60
60
  subject { klass }
61
61
  it { should_not respond_to :register_attributes }
62
62
  it { should_not respond_to :registered_attributes }
63
- it { should_not respond_to :registered_attributes= }
64
63
  end
65
64
 
66
65
  context 'instance' do
@@ -13,7 +13,6 @@ describe FbGraph2::NodeSubClass do
13
13
  subject { klass }
14
14
  it { should respond_to :register_attributes }
15
15
  it { should respond_to :registered_attributes }
16
- it { should respond_to :registered_attributes= }
17
16
  end
18
17
 
19
18
  context 'instance' do
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::Place do
4
+ subject { described_class }
5
+ its(:registered_attributes) { should == FbGraph2::Page.registered_attributes }
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::Struct::AppLink do
4
+ subject { described_class }
5
+ its(:registered_attributes) { should == {raw: [:url]} }
6
+
7
+ describe FbGraph2::Struct::AppLink::Native do
8
+ its(:registered_attributes) { should == {raw: [:url, :app_name]} }
9
+ end
10
+
11
+ describe FbGraph2::Struct::AppLink::Native::IOS do
12
+ its(:registered_attributes) { should == {raw: [:url, :app_name, :app_store_id]} }
13
+ end
14
+
15
+ describe FbGraph2::Struct::AppLink::Native::Android do
16
+ its(:registered_attributes) { should == {raw: [:url, :app_name, :package], custom: [:klass]} }
17
+ end
18
+
19
+ describe FbGraph2::Struct::AppLink::Native::WindowsPhone do
20
+ its(:registered_attributes) { should == {raw: [:url, :app_name, :app_id]} }
21
+ end
22
+
23
+ describe FbGraph2::Struct::AppLink::Web do
24
+ its(:registered_attributes) { should == {raw: [:url, :should_fallback]} }
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "804327549686491",
5
+ "canonical_url": "https://fb.me/804327549686491"
6
+ }
7
+ ],
8
+ "paging": {
9
+ "cursors": {
10
+ "before": "ODA0MzI3NTQ5Njg2NDkx",
11
+ "after": "ODA0MzI3NTQ5Njg2NDkx"
12
+ }
13
+ }
14
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-09 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -313,6 +313,7 @@ files:
313
313
  - lib/fb_graph2/user.rb
314
314
  - lib/fb_graph2/util.rb
315
315
  - lib/fb_graph2/video.rb
316
+ - spec/fb_graph2/app_link_host_spec.rb
316
317
  - spec/fb_graph2/app_spec.rb
317
318
  - spec/fb_graph2/auth_spec.rb
318
319
  - spec/fb_graph2/collection_spec.rb
@@ -321,6 +322,7 @@ files:
321
322
  - spec/fb_graph2/edge/activities_spec.rb
322
323
  - spec/fb_graph2/edge/admins_spec.rb
323
324
  - spec/fb_graph2/edge/albums_spec.rb
325
+ - spec/fb_graph2/edge/app_link_hosts_spec.rb
324
326
  - spec/fb_graph2/edge/applications_spec.rb
325
327
  - spec/fb_graph2/edge/attending_spec.rb
326
328
  - spec/fb_graph2/edge/banned_spec.rb
@@ -373,15 +375,18 @@ files:
373
375
  - spec/fb_graph2/node_spec.rb
374
376
  - spec/fb_graph2/node_subclass_spec.rb
375
377
  - spec/fb_graph2/page_spec.rb
378
+ - spec/fb_graph2/place_spec.rb
376
379
  - spec/fb_graph2/request_filter/authenticator_spec.rb
377
380
  - spec/fb_graph2/request_filter/debugger_spec.rb
378
381
  - spec/fb_graph2/searchable_spec.rb
382
+ - spec/fb_graph2/struct/app_link_spec.rb
379
383
  - spec/fb_graph2/tagged_profile_spec.rb
380
384
  - spec/fb_graph2/token_metadata_spec.rb
381
385
  - spec/fb_graph2/user_spec.rb
382
386
  - spec/fb_graph2/util_spec.rb
383
387
  - spec/fb_graph2_spec.rb
384
388
  - spec/mock_json/app/app.json
389
+ - spec/mock_json/app/app_link_hosts.json
385
390
  - spec/mock_json/app/banned.json
386
391
  - spec/mock_json/app/roles.json
387
392
  - spec/mock_json/app/subscriptions.json