mosaic-facebook 0.1.2 → 0.2.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.
data/.gitignore CHANGED
@@ -3,4 +3,6 @@ pkg/*
3
3
  .bundle
4
4
  .DS_Store
5
5
  Gemfile.lock
6
- spec/facebook_credentials.yml
6
+ spec/facebook_config.yml
7
+ *.swp
8
+ vendor/bundle
@@ -5,6 +5,7 @@ require 'mosaic/facebook/graph/application'
5
5
  require 'mosaic/facebook/graph/comment'
6
6
  require 'mosaic/facebook/graph/insights'
7
7
  require 'mosaic/facebook/graph/page'
8
+ require 'mosaic/facebook/graph/event'
8
9
  require 'mosaic/facebook/graph/post'
9
10
  require 'mosaic/facebook/graph/subscription'
10
- require 'mosaic/facebook/graph/user'
11
+ require 'mosaic/facebook/graph/user'
@@ -0,0 +1,10 @@
1
+ module Mosaic
2
+ module Facebook
3
+ module Graph
4
+ class Event < Mosaic::Facebook::Graph::GraphObject
5
+ attr_accessor :id, :name, :description, :start_time, :end_time, :location, :venue, :updated_time, :picture, :ticket_uri
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,6 +4,10 @@ module Mosaic
4
4
  class Page < Mosaic::Facebook::Graph::GraphObject
5
5
  attr_accessor :id, :name, :picture, :link, :likes, :category, :can_post, :type, :from, :to
6
6
 
7
+ def events
8
+ @events ||= AssociationProxy.new(Mosaic::Facebook::Graph::Event, "/#{self.id}/events")
9
+ end
10
+
7
11
  def feed
8
12
  @feed ||= AssociationProxy.new(Mosaic::Facebook::Graph::Post, "/#{self.id}/feed")
9
13
  end
@@ -4,7 +4,7 @@ module Mosaic
4
4
  module Facebook
5
5
  class Object
6
6
  include HTTParty
7
- debug_output
7
+ # debug_output
8
8
 
9
9
  def initialize(attributes = {})
10
10
  attributes.each { |key,value| instance_variable_set("@#{key}".to_sym, value) }
@@ -1,5 +1,5 @@
1
1
  module Mosaic
2
2
  module Facebook
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ access_token: "Your token goes here"
2
+ page_id: "Pages ID"
3
+ user_id: "Your ID"
@@ -3,24 +3,23 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb
3
3
 
4
4
  describe Mosaic::Facebook::Notification do
5
5
  def options
6
- options = {:recipients => "535004545", :subject => "testing", :text => "ajit", :access_token => "xxx"}
6
+ options = {:recipients => "000000000", :subject => "testing", :text => "ajit", :access_token => "xxx"}
7
7
  end
8
8
 
9
9
  context "when no or invalid token is passed" do
10
10
  it "should require an access_token" do
11
- lambda { Mosaic::Facebook::Notification.send_email(options.merge(:access_token => nil)) }.should raise_error(Mosaic::Facebook::AccessTokenError, /INVALID API KEY/i)
11
+ lambda { Mosaic::Facebook::Notification.send_email(options.merge(:access_token => nil)) }.should raise_error(Mosaic::Facebook::AccessTokenError, /Invalid application ID/i)
12
12
  end
13
13
 
14
14
  it "should require a valid access_token" do
15
- lambda {Mosaic::Facebook::Notification.send_email(options)}.should raise_error(Mosaic::Facebook::AccessTokenError, /INVALID OAUTH ACCESS TOKEN/i)
15
+ lambda {Mosaic::Facebook::Notification.send_email(options.merge(:recipients => RSpec.configuration.user_id))}.should raise_error(Mosaic::Facebook::AccessTokenError, /INVALID OAUTH ACCESS TOKEN/i)
16
16
  end
17
17
 
18
18
  end
19
19
 
20
-
21
20
  context "when a valid access_token is provided" do
22
21
  it "should send a notification" do
23
- Mosaic::Facebook::Notification.send_email(options.merge(:access_token => FBK_CREDS[:token]))
22
+ Mosaic::Facebook::Notification.send_email(options.merge(:recipients => RSpec.configuration.user_id, :access_token => RSpec.configuration.access_token))
24
23
  end
25
24
  end
26
- end
25
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
2
+
3
+ describe Mosaic::Facebook::Graph::Page do
4
+ context "when a valid token and page id are passed" do
5
+ it "should return a page feed" do
6
+ feed = Mosaic::Facebook::Graph::Page.new().feed.all({ :access_token => RSpec.configuration.access_token, :id => RSpec.configuration.page_id })
7
+ feed.should be_an_instance_of Array
8
+ feed.first.should be_an_instance_of Mosaic::Facebook::Graph::Post
9
+ end
10
+
11
+ it "should return a event list" do
12
+ events = Mosaic::Facebook::Graph::Page.new().events.all({ :access_token => RSpec.configuration.access_token, :id => RSpec.configuration.page_id })
13
+ events.should be_an_instance_of Array
14
+ events.first.should be_an_instance_of Mosaic::Facebook::Graph::Event
15
+ end
16
+ end
17
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,4 +11,10 @@ SPEC_DIR = File.dirname(__FILE__)
11
11
  # $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
12
12
 
13
13
  require 'mosaic-facebook'
14
- FBK_CREDS = YAML.load(File.open("#{SPEC_DIR}/facebook_credentials.yml", 'r'))
14
+ FACEBOOK_CONFIG = YAML.load(File.open("#{SPEC_DIR}/facebook_config.yml", 'r'))
15
+
16
+ RSpec.configure do |config|
17
+ config.add_setting :access_token, :default => FACEBOOK_CONFIG["access_token"]
18
+ config.add_setting :user_id, :default => FACEBOOK_CONFIG["user_id"]
19
+ config.add_setting :page_id, :default => FACEBOOK_CONFIG["page_id"]
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mosaic-facebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-12 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -87,6 +87,7 @@ files:
87
87
  - lib/mosaic/facebook/graph/application.rb
88
88
  - lib/mosaic/facebook/graph/association_proxy.rb
89
89
  - lib/mosaic/facebook/graph/comment.rb
90
+ - lib/mosaic/facebook/graph/event.rb
90
91
  - lib/mosaic/facebook/graph/graph_object.rb
91
92
  - lib/mosaic/facebook/graph/insights.rb
92
93
  - lib/mosaic/facebook/graph/page.rb
@@ -98,8 +99,9 @@ files:
98
99
  - lib/mosaic/facebook/version.rb
99
100
  - lib/mosaic_facebook.rb
100
101
  - mosaic-facebook.gemspec
101
- - spec/facebook_credentials.yml.example
102
+ - spec/facebook_config.yml.example
102
103
  - spec/mosaic-facebook/notification_spec.rb
104
+ - spec/mosaic-facebook/page_spec.rb
103
105
  - spec/mosaic-facebook_spec.rb
104
106
  - spec/spec.opts
105
107
  - spec/spec_helper.rb
@@ -128,8 +130,9 @@ signing_key:
128
130
  specification_version: 3
129
131
  summary: gem/plugin to connect to facebook graph api
130
132
  test_files:
131
- - spec/facebook_credentials.yml.example
133
+ - spec/facebook_config.yml.example
132
134
  - spec/mosaic-facebook/notification_spec.rb
135
+ - spec/mosaic-facebook/page_spec.rb
133
136
  - spec/mosaic-facebook_spec.rb
134
137
  - spec/spec.opts
135
138
  - spec/spec_helper.rb
@@ -1 +0,0 @@
1
- token: "Your token goes here"