facebook_sdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in facebook_sdk.gemspec
4
+ gemspec
5
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => :test
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "lib" << "test"
8
+ t.test_files = FileList["test/test_*.rb"]
9
+ t.verbose = true
10
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "facebook_sdk/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "facebook_sdk"
7
+ s.version = FacebookSDK::VERSION
8
+ s.authors = ["Erick Zetta"]
9
+ s.email = ["erick.zetta@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Facebook SDK for Graph API}
12
+ s.description = %q{Facebook SDK for Graph API}
13
+
14
+ s.rubyforge_project = "facebook_sdk"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+
25
+ s.add_development_dependency "test-unit"
26
+ s.add_development_dependency "turn"
27
+
28
+ s.add_runtime_dependency "json"
29
+ s.add_runtime_dependency "hashie"
30
+ s.add_runtime_dependency "faraday"
31
+ end
@@ -0,0 +1,13 @@
1
+
2
+ require 'hashie'
3
+
4
+ module FacebookSDK
5
+ module Api
6
+ def api(url, &block)
7
+ result = get url, &block
8
+
9
+ Hashie::Mash.new result.body
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module FacebookSDK
2
+ class Configuration
3
+ attr_accessor :app_id, :secret, :faraday
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require 'json'
3
+
4
+ module FacebookSDK
5
+ module Middleware
6
+ class JSONDecoder < Faraday::Response::Middleware
7
+
8
+ def on_complete(env)
9
+ env[:body] = JSON.parse env[:body]
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module FacebookSDK
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,40 @@
1
+ require "facebook_sdk/version"
2
+ require "forwardable"
3
+ require "faraday"
4
+
5
+ require "facebook_sdk/configuration"
6
+ require "facebook_sdk/api"
7
+
8
+ require "facebook_sdk/middleware/json_decoder"
9
+
10
+ module FacebookSDK
11
+ class Session
12
+ extend Forwardable
13
+
14
+ include Api
15
+
16
+ GRAPH_URL = "https://graph.facebook.com/"
17
+
18
+ def_delegators :@config, :app_id, :secret
19
+ def_delegators :@conn, :get, :post
20
+
21
+ def initialize(&block)
22
+
23
+ @conn = Faraday.new(:url => GRAPH_URL) do |builder|
24
+ #builder.use Faraday::Response::Logger # log the request to STDOUT
25
+
26
+ builder.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP
27
+ builder.use FacebookSDK::Middleware::JSONDecoder # use own JSONDecoder
28
+
29
+
30
+ @config = Configuration.new
31
+
32
+ @config.faraday = builder
33
+ yield @config
34
+
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ require 'turn'
3
+
4
+ require 'facebook_sdk'
5
+
6
+ module FacebookSDK
7
+ class TestCase < Test::Unit::TestCase
8
+
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
+
3
+ class TestBasic < FacebookSDK::TestCase
4
+ # def setup
5
+ # end
6
+
7
+ # def teardown
8
+ # end
9
+
10
+ def test_get_facebook_platform
11
+ fb = FacebookSDK::Session.new do |config|
12
+
13
+ end
14
+
15
+ p = fb.api '/19292868552'
16
+
17
+ assert_equal "Facebook Platform", p.name
18
+ assert_equal "http://developers.facebook.com", p.website
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: facebook_sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Erick Zetta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-unit
16
+ requirement: &73638110 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *73638110
25
+ - !ruby/object:Gem::Dependency
26
+ name: turn
27
+ requirement: &73637760 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *73637760
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ requirement: &73637430 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *73637430
47
+ - !ruby/object:Gem::Dependency
48
+ name: hashie
49
+ requirement: &73637060 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *73637060
58
+ - !ruby/object:Gem::Dependency
59
+ name: faraday
60
+ requirement: &73636640 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *73636640
69
+ description: Facebook SDK for Graph API
70
+ email:
71
+ - erick.zetta@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - Rakefile
79
+ - facebook_sdk.gemspec
80
+ - lib/facebook_sdk.rb
81
+ - lib/facebook_sdk/api.rb
82
+ - lib/facebook_sdk/configuration.rb
83
+ - lib/facebook_sdk/middleware/json_decoder.rb
84
+ - lib/facebook_sdk/version.rb
85
+ - test/helper.rb
86
+ - test/test_basic.rb
87
+ homepage: ''
88
+ licenses: []
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project: facebook_sdk
107
+ rubygems_version: 1.8.10
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Facebook SDK for Graph API
111
+ test_files: []