fbgraph 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('fbgraph', '0.0.2') do |p|
5
+ Echoe.new('fbgraph', '0.0.4') do |p|
6
6
  p.description = "A Gem for Facebook Open Graph API"
7
7
  p.url = "http://github.com/nsanta/fbgraph"
8
8
  p.author = "Nicolas Santa"
data/fbgraph.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fbgraph}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nicolas Santa"]
9
- s.date = %q{2010-05-07}
9
+ s.date = %q{2010-05-10}
10
10
  s.description = %q{A Gem for Facebook Open Graph API}
11
11
  s.email = %q{nicolas55ar@gmail.com}
12
12
  s.extra_rdoc_files = ["README", "lib/fbgraph.rb", "lib/fbgraph/authorization.rb", "lib/fbgraph/base.rb", "lib/fbgraph/client.rb", "lib/fbgraph/search.rb", "lib/fbgraph/selection.rb"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fbgraph", "--main", "README"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{fbgraph}
18
- s.rubygems_version = %q{1.3.5}
18
+ s.rubygems_version = %q{1.3.6}
19
19
  s.summary = %q{A Gem for Facebook Open Graph API}
20
20
 
21
21
  if s.respond_to? :specification_version then
data/lib/fbgraph/base.rb CHANGED
@@ -6,6 +6,7 @@ module FBGraph
6
6
 
7
7
  def initialize(client)
8
8
  @client = client
9
+ @params = {}
9
10
  end
10
11
 
11
12
 
@@ -30,36 +31,48 @@ module FBGraph
30
31
  def info(parsed = true)
31
32
  if @objects.is_a? Array
32
33
  @params.merge!({:ids => ids.join(',')})
33
- uri = build_open_graph_uri(nil , nil , @params)
34
+ uri = "/"
34
35
  elsif @objects.is_a? String
35
- uri = build_open_graph_uri(@objects , @connection_type , @params)
36
+ uri = build_open_graph_path(@objects , @connection_type)
36
37
  end
38
+ puts "FBGRAPH [GET]: #{uri}"
37
39
  result = @client.consumer.get(uri)
38
40
  return parsed ? JSON.parse(result) : result
39
41
  end
40
42
 
41
43
 
42
- def publish(parsed = true)
43
- consume!(:post , parsed)
44
+ def publish(data = {},parsed = true)
45
+ @params.merge!(data)
46
+ uri = build_open_graph_path(@objects , @connection_type)
47
+ puts "FBGRAPH [POST]: #{uri}"
48
+ result = @client.consumer.post(uri , @params)
49
+ return parsed ? JSON.parse(result) : result
44
50
  end
45
51
 
46
52
  def delete(parsed = true)
47
- @params = {:method => 'delete'}
48
- consume!(:post, parsed)
53
+ uri = build_open_graph_path(@objects , nil)
54
+ puts "FBGRAPH [DELETE]: #{uri}"
55
+ result = @client.consumer.delete(uri , @params)
56
+ return parsed ? JSON.parse(result) : result
49
57
  end
50
-
58
+
59
+ %w(limit offset until since).each do |paging|
60
+ class_eval <<-PAGING
61
+ def #{paging}(value)
62
+ @params[:#{paging}] = value
63
+ end
64
+ PAGING
65
+
66
+ end
67
+
68
+
51
69
  private
52
70
 
53
- def build_open_graph_uri(id,connection_type = nil, params = {})
54
- request = "/" + [id , connection_type].compact.join('/')
55
- request += "?"+params.to_a.map{|p| p.join('=')}.join('&')
71
+ def build_open_graph_path(objects,connection_type = nil , params = {})
72
+ request = "/" + [objects , connection_type].compact.join('/')
73
+ request += "?"+params.to_a.map{|p| p.join('=')}.join('&') unless params.empty?
56
74
  request
57
75
  end
58
-
59
- def consume!(verb, parse)
60
- uri = build_open_graph_uri(@objects , @connection_type , @params)
61
- result = @client.consumer.send(verb,uri)
62
- return parsed ? JSON.parse(result) : result
63
- end
76
+
64
77
  end
65
78
  end
@@ -1,40 +1,46 @@
1
1
  module FBGraph
2
2
  class Selection < Base
3
3
 
4
- def me
5
- find('me')
6
- end
7
-
8
- OBJECTS = %w(user album event group link note page photo post status video).freeze
4
+ OBJECTS = %w(user album event group link note page photo post status video).freeze
9
5
 
10
- CONNECTION_TYPES = %w(home photos comments feed noreply
11
- maybe invited attending declined picture
12
- members picture tagged links groups albums
13
- statuses videos notes posts events friends
14
- activities interests music books movies television
15
- likes inbox outbox updates).freeze
6
+ CONNECTION_TYPES = %w(home photos comments feed noreply
7
+ maybe invited attending declined picture
8
+ members picture tagged links groups albums
9
+ statuses videos notes posts events friends
10
+ activities interests music books movies television
11
+ likes inbox outbox updates).freeze
16
12
 
17
- OBJECTS.each do |object|
18
- class_eval <<-METHOD
19
- def #{object}(object)
20
- find(object)
21
- self
22
- end
13
+ OBJECTS.each do |object|
14
+ class_eval <<-METHOD
15
+ def #{object}(object)
16
+ find(object)
17
+ self
18
+ end
23
19
  METHOD
24
- end
20
+ end
25
21
 
26
- CONNECTION_TYPES.each do |object|
27
- class_eval <<-METHOD
28
- def #{object}(object)
29
- connection(object)
30
- self
31
- end
32
- METHOD
33
- end
22
+ CONNECTION_TYPES.each do |object|
23
+ class_eval <<-METHOD
24
+ def #{object}
25
+ connection('#{object}')
26
+ self
27
+ end
28
+ METHOD
29
+ end
30
+
31
+
32
+ def me
33
+ find('me')
34
+ end
34
35
 
35
- def metadata
36
- @params.merge!({:metadata => '1'})
37
- self
38
- end
36
+ def metadata
37
+ @params.merge!({:metadata => '1'})
38
+ self
39
+ end
40
+
41
+ def picture
42
+ @client.facebook_uri + build_open_graph_path(@objects , 'picture')
43
+ end
44
+
39
45
  end
40
46
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 4
9
+ version: 0.0.4
5
10
  platform: ruby
6
11
  authors:
7
12
  - Nicolas Santa
@@ -9,19 +14,21 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-05-07 00:00:00 -03:00
17
+ date: 2010-05-10 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: oauth2
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :development
31
+ version_requirements: *id001
25
32
  description: A Gem for Facebook Open Graph API
26
33
  email: nicolas55ar@gmail.com
27
34
  executables: []
@@ -68,18 +75,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
75
  requirements:
69
76
  - - ">="
70
77
  - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
71
80
  version: "0"
72
- version:
73
81
  required_rubygems_version: !ruby/object:Gem::Requirement
74
82
  requirements:
75
83
  - - ">="
76
84
  - !ruby/object:Gem::Version
85
+ segments:
86
+ - 1
87
+ - 2
77
88
  version: "1.2"
78
- version:
79
89
  requirements: []
80
90
 
81
91
  rubyforge_project: fbgraph
82
- rubygems_version: 1.3.5
92
+ rubygems_version: 1.3.6
83
93
  signing_key:
84
94
  specification_version: 3
85
95
  summary: A Gem for Facebook Open Graph API