Skip to content
Browse files

Adding Facebook Graph as an example app

  • Loading branch information...
1 parent c2f2b2b commit bc4232aec931f850d5f20bb48b3c9dc9fbff1e24 @clayallsopp committed
View
2 examples/FacebookGraph/.gitignore
@@ -0,0 +1,2 @@
+.repl_history
+build
View
10 examples/FacebookGraph/Rakefile
@@ -0,0 +1,10 @@
+$:.unshift("/Library/RubyMotion/lib")
+require 'motion/project'
+
+Motion::Project::App.setup do |app|
+ # Use `rake config' to see complete project settings.
+ app.name = 'FacebookGraph'
+ app.files = Dir.glob(File.join(app.project_dir, '../../vendor/BubbleWrap/lib/**/*.rb')) +
+ Dir.glob(File.join(app.project_dir, '../../lib/**/*.rb')) +
+ app.files
+end
View
5 examples/FacebookGraph/app/app_delegate.rb
@@ -0,0 +1,5 @@
+class AppDelegate
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
+ true
+ end
+end
View
12 examples/FacebookGraph/app/initializers/remote_model.rb
@@ -0,0 +1,12 @@
+module RemoteModule
+ class RemoteModel
+ self.root_url = "https://graph.facebook.com/"
+ self.extension = ""
+
+ self.default_url_options = {
+ :query => {
+ "access_token" => "AAAAAAITEghMBAOKs0vDSPuxPZAZBZBUcP1ruJaZC2ZARYKU0j5goBI3ZCZB9K5qgzvIzwwGM1zvDxJlnbOk8Bv6PZAlButKV5cp7NRTbviyWU4cwlCIwjZCdB",
+ }
+ }
+ end
+end
View
35 examples/FacebookGraph/app/models/User.rb
@@ -0,0 +1,35 @@
+class User < RemoteModule::RemoteModel
+ attr_accessor :id, :name, :bio
+
+ has_many :wall_posts
+ has_many :friends => :user
+
+ collection_url ""
+ member_url ":id"
+
+ custom_urls :friends_url => member_url + "/friends",
+ :wall_posts_url => member_url + "/feed"
+
+ # EX
+ # user.find_friends do |user|
+ # p user.friends[0]
+ # end
+ def find_friends(&block)
+ get(self.friends_url) do |response, json|
+ self.friends = json[:data]
+ if block
+ block.call self
+ end
+ end
+ end
+
+ def find_wall_posts(&block)
+ get(self.wall_posts_url) do |response, json|
+
+ self.wall_posts = json[:data]
+ if block
+ block.call self
+ end
+ end
+ end
+end
View
8 examples/FacebookGraph/app/models/WallPost.rb
@@ -0,0 +1,8 @@
+class WallPost < RemoteModule::RemoteModel
+ attr_accessor :id, :message
+
+ has_one :from => :user
+
+ collection_url ""
+ member_url ":id"
+end
View
9 examples/FacebookGraph/spec/main_spec.rb
@@ -0,0 +1,9 @@
+describe "Application 'FacebookGraph'" do
+ before do
+ @app = UIApplication.sharedApplication
+ end
+
+ it "has one window" do
+ @app.windows.size.should == 1
+ end
+end

0 comments on commit bc4232a

Please sign in to comment.
Something went wrong with that request. Please try again.