facebook_light 0.0.2dev → 0.0.3dev

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,17 @@
1
1
  require "base64"
2
2
  require "openssl"
3
+ require "cocaine"
3
4
  require "facebook_light/version"
4
5
  require "facebook_light/request"
5
6
  require "facebook_light/client"
6
7
 
7
8
  module FacebookLight
8
9
 
10
+ API_URL = "https://api.facebook.com"
11
+ GRAPH_URL = "https://graph.facebook.com"
12
+
9
13
  def self.settings
10
- @@settings ||= {
11
- :site => "https://graph.facebook.com"
12
- }
14
+ @@settings ||= {}
13
15
  end
14
16
 
15
17
  def self.settings=(settings)
@@ -45,10 +45,14 @@ module FacebookLight
45
45
  self.access_token = access_token
46
46
  end
47
47
 
48
- def get(query, options = {})
49
- host = options[:site] || FacebookLight.settings[:site]
50
- url = "#{host}#{query}?access_token=#{access_token}"
51
- JSON.parse(Request.new(url).run).with_indifferent_access
48
+ def get(query)
49
+ url = File.join(GRAPH_URL, "#{query}?access_token=#{access_token}")
50
+ Request.new(url).run.as_json
51
+ end
52
+
53
+ def fql(query)
54
+ url = File.join(API_URL, "method/fql.query?format=json&query=#{CGI.escape(query)}&access_token=#{access_token}")
55
+ Request.new(url).run.as_json
52
56
  end
53
57
 
54
58
  end
@@ -15,7 +15,12 @@ module FacebookLight
15
15
  end
16
16
 
17
17
  def run
18
- self.dispatcher.run
18
+ response = self.dispatcher.run
19
+ def response.as_json
20
+ result = JSON.parse(self)
21
+ result.is_a?(Array) ? result.map(&:with_indifferent_access) : result.with_indifferent_access
22
+ end
23
+ response
19
24
  end
20
25
 
21
26
  end
@@ -1,3 +1,3 @@
1
1
  module FacebookLight
2
- VERSION = "0.0.2dev"
2
+ VERSION = "0.0.3dev"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2dev
4
+ version: 0.0.3dev
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-25 00:00:00.000000000Z
12
+ date: 2011-12-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &10667740 !ruby/object:Gem::Requirement
16
+ requirement: &20020600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *10667740
24
+ version_requirements: *20020600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cocaine
27
- requirement: &10667300 !ruby/object:Gem::Requirement
27
+ requirement: &20020040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *10667300
35
+ version_requirements: *20020040
36
36
  description: A transparent facebook api implementation that doesn't obscure requests
37
37
  email:
38
38
  - daniel@viseztrance.com