fbrails 0.0.8 → 0.0.9

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.
data/lib/fbrails/graph.rb CHANGED
@@ -1,19 +1,21 @@
1
1
  module Fbrails
2
2
  class Graph
3
+
4
+ URL = "https://graph.facebook.com/"
5
+
3
6
  def initialize(token)
4
7
  @token = token
5
8
  end
6
9
 
7
- def get_object(obj = "")
8
- url = "https://graph.facebook.com/me/#{obj}?access_token=#{@token}"
9
- Fbrails.get(url)
10
- end
11
-
10
+ # def get_object(obj = "")
11
+ # url = "https://graph.facebook.com/me/#{obj}?access_token=#{@token}"
12
+ # Fbrails.get(url)
13
+ # end
12
14
 
13
15
  #graph.get_picture(ID,TYPE)
14
16
  #TYPE can be square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), large (about 200 pixels wide, variable height)
15
- def self.get_picture(id,type=nil)
16
- first = "http://graph.facebook.com/#{id}/picture"
17
+ def self.get_picture(id,type=nil)
18
+ first = "http://graph.facebook.com/#{id}/picture"
17
19
  if type.blank?
18
20
  return first
19
21
  elsif type == 'square' || type == 'small' || type == 'normal' || type == 'large'
@@ -21,8 +23,38 @@ module Fbrails
21
23
  end
22
24
  end
23
25
 
26
+ # Fbrails::Graph.me_books
24
27
 
28
+ def method_missing (method)
29
+ call(method)
30
+ end
31
+
32
+ def access_token
33
+ "?access_token=#{@token}"
34
+ end
25
35
 
26
-
36
+ def call (method)
37
+ url = method.to_s.split("_").join("/")
38
+ get(URL+url+access_token)
39
+ end
40
+
41
+ def get (url,raw = false)
42
+ uri = URI.parse(url)
43
+ http = Net::HTTP.new(uri.host,uri.port)
44
+ http.use_ssl = true
45
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
+ request = Net::HTTP::Get.new(uri.request_uri)
47
+ resp = http.request(request)
48
+ if raw
49
+ return resp.body
50
+ end
51
+ result = JSON.parse(resp.body)
52
+ if result.has_key?("error")
53
+ raise FailedToGet, "Failed to get, probably token expired"
54
+ else
55
+ return result
56
+ end
57
+ end
58
+
27
59
  end
28
60
  end
@@ -1,3 +1,3 @@
1
1
  module Fbrails
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/fbrails.rb CHANGED
@@ -7,24 +7,27 @@ module Fbrails
7
7
  class FailedToGet < StandardError
8
8
  end
9
9
 
10
- def self.get(url,raw = false)
11
- uri = URI.parse(url)
12
- http = Net::HTTP.new(uri.host,uri.port)
13
- http.use_ssl = true
14
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
- request = Net::HTTP::Get.new(uri.request_uri)
16
- resp = http.request(request)
17
- if raw
18
- return resp.body
10
+ def get (url,raw = false)
11
+ uri = URI.parse(url)
12
+ http = Net::HTTP.new(uri.host,uri.port)
13
+ http.use_ssl = true
14
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
+ request = Net::HTTP::Get.new(uri.request_uri)
16
+ resp = http.request(request)
17
+ if raw
18
+ return resp.body
19
+ end
20
+ result = JSON.parse(resp.body)
21
+ if result.has_key?("error")
22
+ raise FailedToGet, "Failed to get, probably token expired"
23
+ else
24
+ return result
25
+ end
19
26
  end
20
27
 
21
- result = JSON.parse(resp.body)
22
- if result.has_key?("error")
23
- raise FailedToGet, "Failed to get, probably token expired"
24
- else
25
- return result
26
- end
27
- end
28
+ def self.put(url)
29
+
30
+ end
28
31
 
29
32
  require 'fbrails/auth'
30
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-06 00:00:00.000000000Z
14
+ date: 2011-10-12 00:00:00.000000000Z
15
15
  dependencies: []
16
16
  description: Small gem for auth & getting info from facebook
17
17
  email: