tenderlove-facebooker 1.0.16.20090319151701

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/COPYING.rdoc +19 -0
  3. data/Manifest.txt +123 -0
  4. data/README.rdoc +103 -0
  5. data/Rakefile +86 -0
  6. data/TODO.rdoc +4 -0
  7. data/examples/desktop_login.rb +14 -0
  8. data/facebooker.gemspec +38 -0
  9. data/generators/facebook/facebook_generator.rb +14 -0
  10. data/generators/facebook/templates/config/facebooker.yml +46 -0
  11. data/generators/facebook/templates/public/javascripts/facebooker.js +99 -0
  12. data/generators/facebook_controller/USAGE +33 -0
  13. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  14. data/generators/facebook_controller/templates/controller.rb +7 -0
  15. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  16. data/generators/facebook_controller/templates/helper.rb +2 -0
  17. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  18. data/generators/facebook_controller/templates/view.html.erb +2 -0
  19. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  20. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  21. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  22. data/generators/facebook_scaffold/USAGE +27 -0
  23. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  24. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  25. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  26. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  27. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  28. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  29. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  30. data/generators/facebook_scaffold/templates/style.css +74 -0
  31. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  32. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  33. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  34. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  35. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  36. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  37. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  38. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  39. data/generators/publisher/publisher_generator.rb +14 -0
  40. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  41. data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
  42. data/init.rb +72 -0
  43. data/install.rb +12 -0
  44. data/lib/facebooker/adapters/adapter_base.rb +87 -0
  45. data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
  46. data/lib/facebooker/adapters/facebook_adapter.rb +52 -0
  47. data/lib/facebooker/admin.rb +42 -0
  48. data/lib/facebooker/batch_request.rb +44 -0
  49. data/lib/facebooker/data.rb +57 -0
  50. data/lib/facebooker/feed.rb +78 -0
  51. data/lib/facebooker/logging.rb +51 -0
  52. data/lib/facebooker/mobile.rb +20 -0
  53. data/lib/facebooker/mock/service.rb +50 -0
  54. data/lib/facebooker/mock/session.rb +18 -0
  55. data/lib/facebooker/model.rb +135 -0
  56. data/lib/facebooker/models/affiliation.rb +10 -0
  57. data/lib/facebooker/models/album.rb +11 -0
  58. data/lib/facebooker/models/applicationproperties.rb +39 -0
  59. data/lib/facebooker/models/applicationrestrictions.rb +10 -0
  60. data/lib/facebooker/models/cookie.rb +10 -0
  61. data/lib/facebooker/models/education_info.rb +11 -0
  62. data/lib/facebooker/models/event.rb +28 -0
  63. data/lib/facebooker/models/friend_list.rb +16 -0
  64. data/lib/facebooker/models/group.rb +36 -0
  65. data/lib/facebooker/models/info_item.rb +10 -0
  66. data/lib/facebooker/models/info_section.rb +10 -0
  67. data/lib/facebooker/models/location.rb +8 -0
  68. data/lib/facebooker/models/notifications.rb +17 -0
  69. data/lib/facebooker/models/page.rb +27 -0
  70. data/lib/facebooker/models/photo.rb +12 -0
  71. data/lib/facebooker/models/tag.rb +12 -0
  72. data/lib/facebooker/models/user.rb +426 -0
  73. data/lib/facebooker/models/video.rb +9 -0
  74. data/lib/facebooker/models/work_info.rb +9 -0
  75. data/lib/facebooker/parser.rb +589 -0
  76. data/lib/facebooker/rails/controller.rb +304 -0
  77. data/lib/facebooker/rails/cucumber/world.rb +46 -0
  78. data/lib/facebooker/rails/cucumber.rb +28 -0
  79. data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
  80. data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
  81. data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
  82. data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
  83. data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
  84. data/lib/facebooker/rails/facebook_url_rewriting.rb +39 -0
  85. data/lib/facebooker/rails/helpers/fb_connect.rb +89 -0
  86. data/lib/facebooker/rails/helpers.rb +762 -0
  87. data/lib/facebooker/rails/integration_session.rb +38 -0
  88. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  89. data/lib/facebooker/rails/publisher.rb +526 -0
  90. data/lib/facebooker/rails/routing.rb +49 -0
  91. data/lib/facebooker/rails/test_helpers.rb +68 -0
  92. data/lib/facebooker/rails/utilities.rb +22 -0
  93. data/lib/facebooker/server_cache.rb +24 -0
  94. data/lib/facebooker/service.rb +94 -0
  95. data/lib/facebooker/session.rb +584 -0
  96. data/lib/facebooker/version.rb +9 -0
  97. data/lib/facebooker.rb +174 -0
  98. data/lib/net/http_multipart_post.rb +123 -0
  99. data/lib/tasks/facebooker.rake +18 -0
  100. data/lib/tasks/tunnel.rake +46 -0
  101. data/rails/init.rb +1 -0
  102. data/setup.rb +1585 -0
  103. data/templates/layout.erb +24 -0
  104. data/test/facebooker/adapters_test.rb +96 -0
  105. data/test/facebooker/admin_test.rb +102 -0
  106. data/test/facebooker/batch_request_test.rb +83 -0
  107. data/test/facebooker/data_test.rb +86 -0
  108. data/test/facebooker/logging_test.rb +43 -0
  109. data/test/facebooker/mobile_test.rb +45 -0
  110. data/test/facebooker/model_test.rb +123 -0
  111. data/test/facebooker/models/event_test.rb +15 -0
  112. data/test/facebooker/models/user_test.rb +295 -0
  113. data/test/facebooker/rails/publisher_test.rb +452 -0
  114. data/test/facebooker/rails_integration_test.rb +1312 -0
  115. data/test/facebooker/server_cache_test.rb +44 -0
  116. data/test/facebooker/session_test.rb +614 -0
  117. data/test/facebooker_test.rb +925 -0
  118. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  119. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  120. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  121. data/test/net/http_multipart_post_test.rb +52 -0
  122. data/test/rails_test_helper.rb +11 -0
  123. data/test/test_helper.rb +66 -0
  124. metadata +217 -0
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ === 1.0.13 / 2009-02-26
2
+
3
+ * Modified fql_query to return results as Hashes as a last resort [Alan Larkin]
4
+ * fixed typo in set app properties parser [Andrew Grim, shane]
5
+ * Removed actor_id param from templatized feed [shane]
6
+ * Added admin.get_allocation [shane]
7
+ * Added data.get_cookies and data.set_cookie [shane]
8
+ * Added admin.get_app_properties and admin.set_app_properties [shane]
9
+
10
+ === 0.9.9 / 2008-09-08
11
+
12
+ * Re-package as gem after reworking for new API
13
+
14
+
15
+ === 0.9.5 / 2008-02-13
16
+
17
+ * Next release of documentation
data/COPYING.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright (c) 2007 Chad Fowler <chad@infoether.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in the
6
+ # Software without restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8
+ # Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,123 @@
1
+ CHANGELOG.rdoc
2
+ COPYING.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ TODO.rdoc
7
+ examples/desktop_login.rb
8
+ facebooker.gemspec
9
+ generators/facebook/facebook_generator.rb
10
+ generators/facebook/templates/config/facebooker.yml
11
+ generators/facebook/templates/public/javascripts/facebooker.js
12
+ generators/facebook_controller/USAGE
13
+ generators/facebook_controller/facebook_controller_generator.rb
14
+ generators/facebook_controller/templates/controller.rb
15
+ generators/facebook_controller/templates/functional_test.rb
16
+ generators/facebook_controller/templates/helper.rb
17
+ generators/facebook_controller/templates/view.fbml.erb
18
+ generators/facebook_controller/templates/view.html.erb
19
+ generators/facebook_publisher/facebook_publisher_generator.rb
20
+ generators/facebook_publisher/templates/create_facebook_templates.rb
21
+ generators/facebook_publisher/templates/publisher.rb
22
+ generators/facebook_scaffold/USAGE
23
+ generators/facebook_scaffold/facebook_scaffold_generator.rb
24
+ generators/facebook_scaffold/templates/controller.rb
25
+ generators/facebook_scaffold/templates/facebook_style.css
26
+ generators/facebook_scaffold/templates/functional_test.rb
27
+ generators/facebook_scaffold/templates/helper.rb
28
+ generators/facebook_scaffold/templates/layout.fbml.erb
29
+ generators/facebook_scaffold/templates/layout.html.erb
30
+ generators/facebook_scaffold/templates/style.css
31
+ generators/facebook_scaffold/templates/view_edit.fbml.erb
32
+ generators/facebook_scaffold/templates/view_edit.html.erb
33
+ generators/facebook_scaffold/templates/view_index.fbml.erb
34
+ generators/facebook_scaffold/templates/view_index.html.erb
35
+ generators/facebook_scaffold/templates/view_new.fbml.erb
36
+ generators/facebook_scaffold/templates/view_new.html.erb
37
+ generators/facebook_scaffold/templates/view_show.fbml.erb
38
+ generators/facebook_scaffold/templates/view_show.html.erb
39
+ generators/publisher/publisher_generator.rb
40
+ generators/xd_receiver/templates/xd_receiver.html
41
+ generators/xd_receiver/xd_receiver_generator.rb
42
+ init.rb
43
+ install.rb
44
+ lib/facebooker.rb
45
+ lib/facebooker/adapters/adapter_base.rb
46
+ lib/facebooker/adapters/bebo_adapter.rb
47
+ lib/facebooker/adapters/facebook_adapter.rb
48
+ lib/facebooker/admin.rb
49
+ lib/facebooker/batch_request.rb
50
+ lib/facebooker/data.rb
51
+ lib/facebooker/feed.rb
52
+ lib/facebooker/logging.rb
53
+ lib/facebooker/mobile.rb
54
+ lib/facebooker/mock/service.rb
55
+ lib/facebooker/mock/session.rb
56
+ lib/facebooker/model.rb
57
+ lib/facebooker/models/affiliation.rb
58
+ lib/facebooker/models/album.rb
59
+ lib/facebooker/models/applicationproperties.rb
60
+ lib/facebooker/models/applicationrestrictions.rb
61
+ lib/facebooker/models/cookie.rb
62
+ lib/facebooker/models/education_info.rb
63
+ lib/facebooker/models/event.rb
64
+ lib/facebooker/models/friend_list.rb
65
+ lib/facebooker/models/group.rb
66
+ lib/facebooker/models/info_item.rb
67
+ lib/facebooker/models/info_section.rb
68
+ lib/facebooker/models/location.rb
69
+ lib/facebooker/models/notifications.rb
70
+ lib/facebooker/models/page.rb
71
+ lib/facebooker/models/photo.rb
72
+ lib/facebooker/models/tag.rb
73
+ lib/facebooker/models/user.rb
74
+ lib/facebooker/models/video.rb
75
+ lib/facebooker/models/work_info.rb
76
+ lib/facebooker/parser.rb
77
+ lib/facebooker/rails/controller.rb
78
+ lib/facebooker/rails/cucumber.rb
79
+ lib/facebooker/rails/cucumber/world.rb
80
+ lib/facebooker/rails/facebook_form_builder.rb
81
+ lib/facebooker/rails/facebook_pretty_errors.rb
82
+ lib/facebooker/rails/facebook_request_fix.rb
83
+ lib/facebooker/rails/facebook_session_handling.rb
84
+ lib/facebooker/rails/facebook_url_helper.rb
85
+ lib/facebooker/rails/facebook_url_rewriting.rb
86
+ lib/facebooker/rails/helpers.rb
87
+ lib/facebooker/rails/helpers/fb_connect.rb
88
+ lib/facebooker/rails/integration_session.rb
89
+ lib/facebooker/rails/profile_publisher_extensions.rb
90
+ lib/facebooker/rails/publisher.rb
91
+ lib/facebooker/rails/routing.rb
92
+ lib/facebooker/rails/test_helpers.rb
93
+ lib/facebooker/rails/utilities.rb
94
+ lib/facebooker/server_cache.rb
95
+ lib/facebooker/service.rb
96
+ lib/facebooker/session.rb
97
+ lib/facebooker/version.rb
98
+ lib/net/http_multipart_post.rb
99
+ lib/tasks/facebooker.rake
100
+ lib/tasks/tunnel.rake
101
+ rails/init.rb
102
+ setup.rb
103
+ templates/layout.erb
104
+ test/facebooker/adapters_test.rb
105
+ test/facebooker/admin_test.rb
106
+ test/facebooker/batch_request_test.rb
107
+ test/facebooker/data_test.rb
108
+ test/facebooker/logging_test.rb
109
+ test/facebooker/mobile_test.rb
110
+ test/facebooker/model_test.rb
111
+ test/facebooker/models/event_test.rb
112
+ test/facebooker/models/user_test.rb
113
+ test/facebooker/rails/publisher_test.rb
114
+ test/facebooker/rails_integration_test.rb
115
+ test/facebooker/server_cache_test.rb
116
+ test/facebooker/session_test.rb
117
+ test/facebooker_test.rb
118
+ test/fixtures/multipart_post_body_with_only_parameters.txt
119
+ test/fixtures/multipart_post_body_with_single_file.txt
120
+ test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt
121
+ test/net/http_multipart_post_test.rb
122
+ test/rails_test_helper.rb
123
+ test/test_helper.rb
data/README.rdoc ADDED
@@ -0,0 +1,103 @@
1
+ = Facebooker
2
+
3
+ * http://facebooker.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
8
+
9
+ * Idiomatic Ruby
10
+ * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem)
11
+ * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available
12
+ * Well tested
13
+
14
+
15
+ == FEATURES/PROBLEMS:
16
+
17
+ * Idiomatic Ruby
18
+ * No dependencies outside of the Ruby standard library
19
+ * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available
20
+ * Well tested
21
+
22
+ == SYNOPSIS:
23
+
24
+ View David Clements' {excellent tutorial}[http://apps.facebook.com/facebooker_tutorial] at {http://apps.facebook.com/facebooker_tutorial/}[http://apps.facebook.com/facebooker_tutorial] or check out {Developing Facebook Platform Applications with Rails}[http://www.pragprog.com/titles/mmfacer].
25
+
26
+ == REQUIREMENTS:
27
+
28
+ None
29
+
30
+ == INSTALL:
31
+
32
+ === Non Rails
33
+
34
+ The best way is:
35
+
36
+ gem install facebooker
37
+
38
+ If, for some reason, you can't/won't use RubyGems, you can do:
39
+
40
+ (sudo) ruby setup.rb
41
+
42
+ === Rails
43
+
44
+ Facebooker can be installed as a Rails plugin by:
45
+
46
+ script/plugin install git://github.com/mmangino/facebooker.git
47
+
48
+ If you don't have git, the plugin can be downloaded from http://github.com/mmangino/facebooker/tarball/master
49
+
50
+ Once the plugin is installed, you will need to configure your Facebook app in config/facebooker.yml.
51
+
52
+ Your application users will need to have added the application in facebook to access all of facebooker's features. You enforce this by adding
53
+
54
+ ensure_application_is_installed_by_facebook_user
55
+
56
+ to your application controller.
57
+
58
+ == using MemCache session
59
+
60
+ Facebook uses some non alphanum characters in the session identifier which interfere with memcache stored sessions. If you want to use MemCache for storing sessions, you can override the valid session id method on memcache by placing the following code in an initializer:
61
+
62
+ # add - as an okay key
63
+ class CGI
64
+ class Session
65
+ class MemCacheStore
66
+ def check_id(id) #:nodoc:#
67
+ /[^0-9a-zA-Z\-\._]+/ =~ id.to_s ? false : true
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+ == LICENSE:
75
+
76
+ (The MIT License)
77
+
78
+ Copyright (c) 2008-2009:
79
+
80
+ * Chad Fowler
81
+ * Patrick Ewing
82
+ * Mike Mangino
83
+ * Shane Vitarana
84
+ * Corey Innis
85
+
86
+ Permission is hereby granted, free of charge, to any person obtaining
87
+ a copy of this software and associated documentation files (the
88
+ 'Software'), to deal in the Software without restriction, including
89
+ without limitation the rights to use, copy, modify, merge, publish,
90
+ distribute, sublicense, and/or sell copies of the Software, and to
91
+ permit persons to whom the Software is furnished to do so, subject to
92
+ the following conditions:
93
+
94
+ The above copyright notice and this permission notice shall be
95
+ included in all copies or substantial portions of the Software.
96
+
97
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
98
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
99
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
100
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
101
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
102
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
103
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,86 @@
1
+ # -*- ruby -*-
2
+ #
3
+ require 'rubygems'
4
+ ENV['RUBY_FLAGS']="-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
5
+ require 'hoe'
6
+ begin
7
+ require 'load_multi_rails_rake_tasks'
8
+ rescue LoadError
9
+ $stderr.puts "Install the multi_rails gem to run tests against multiple versions of Rails"
10
+ end
11
+
12
+ $: << File.dirname(__FILE__) + '/lib'
13
+ require './lib/facebooker.rb'
14
+
15
+ HOE = Hoe.new('facebooker', Facebooker::VERSION::STRING) do |p|
16
+ p.rubyforge_name = 'facebooker'
17
+ p.author = ['Chad Fowler', 'Patrick Ewing', 'Mike Mangino', 'Shane Vitarana', 'Corey Innis']
18
+ p.email = 'mmangino@elevatedrails.com'
19
+ p.readme_file = 'README.rdoc'
20
+ p.history_file = 'CHANGELOG.rdoc'
21
+ p.remote_rdoc_dir = '' # Release to root
22
+ p.test_globs = 'test/**/*_test.rb'
23
+ p.extra_deps << ['json', '>= 1.0.0']
24
+ p.extra_rdoc_files = FileList['*.rdoc']
25
+ end
26
+
27
+ require 'rcov/rcovtask'
28
+
29
+ namespace :test do
30
+ namespace :coverage do
31
+ desc "Delete aggregate coverage data."
32
+ task(:clean) { rm_f "coverage.data" }
33
+ end
34
+ desc 'Aggregate code coverage for unit, functional and integration tests'
35
+ Rcov::RcovTask.new(:coverage) do |t|
36
+ t.libs << "test"
37
+ t.test_files = FileList["test/**/*_test.rb"]
38
+ t.output_dir = "coverage/"
39
+ t.verbose = true
40
+ t.rcov_opts = ['--exclude', 'test,/usr/lib/ruby,/Library/Ruby,/System/Library', '--sort', 'coverage']
41
+ end
42
+ end
43
+
44
+ namespace :gem do
45
+ task :spec do
46
+ File.open("#{HOE.name}.gemspec", 'w') do |f|
47
+ f.write(HOE.spec.to_ruby)
48
+ end
49
+ end
50
+
51
+ namespace :spec do
52
+ task :dev do
53
+ File.open("#{HOE.name}.gemspec", 'w') do |f|
54
+ HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
55
+ f.write(HOE.spec.to_ruby)
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ # vim: syntax=Ruby
62
+ #
63
+ #
64
+ # require File.dirname(__FILE__) + '/vendor/gardener/lib/gardener'
65
+ #
66
+ # require 'facebooker'
67
+ #
68
+ # namespace :doc do
69
+ # task :readme do
70
+ # puts "Readme"
71
+ # end
72
+ # end
73
+ #
74
+ # Gardener.configure do
75
+ # gem_spec do |spec|
76
+ # spec.name = 'facebooker'
77
+ # spec.version = Gem::Version.new(Facebooker::VERSION::STRING)
78
+ # spec.summary = "Pure, idiomatic Ruby wrapper for the Facebook REST API."
79
+ # spec.email = 'chad@infoether.com'
80
+ # spec.author = ['Chad Fowler', 'Patrick Ewing','Mike Mangino','Shane Vitarana']
81
+ # spec.extra_rdoc_files = %w(COPYING)
82
+ # spec.rdoc_options = ['--title', "Gardener",
83
+ # '--main', 'README',
84
+ # '--line-numbers', '--inline-source']
85
+ # end
86
+ # end
data/TODO.rdoc ADDED
@@ -0,0 +1,4 @@
1
+ [ ] Document session handling. Come up with different cases and paths for the flow and create tests for each
2
+ [ ] Verify that sessions are used only where required. Raise exceptions on User methods that require a session when none is available
3
+ [ ] Refactor setup / Adapter loading code
4
+
@@ -0,0 +1,14 @@
1
+ $: << File.join(File.dirname(__FILE__), "..", 'lib')
2
+ require 'facebooker'
3
+ load "~/.facebooker" rescue fail("You'll need to specify API_KEY and SECRET_KEY to run this example. One way to do that would be to put them in ~/.facebooker")
4
+ session = Facebooker::Session::Desktop.create(API_KEY, SECRET_KEY)
5
+ puts session.login_url
6
+ gets
7
+
8
+ session.user.friends!.each do |user|
9
+ puts "#{user.id}:#{user.name}"
10
+ end
11
+ # This time all the data is there because friends! has already retrieved it.
12
+ session.user.friends.each do |user|
13
+ puts "#{user.id}:#{user.name}"
14
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{facebooker}
5
+ s.version = "1.0.16.20090319151701"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis"]
9
+ s.date = %q{2009-03-19}
10
+ s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are: * Idiomatic Ruby * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem) * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available * Well tested}
11
+ s.email = %q{mmangino@elevatedrails.com}
12
+ s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
13
+ s.files = ["CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://facebooker.rubyforge.org}
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{facebooker}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]}
21
+ s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<json>, [">= 1.0.0"])
29
+ s.add_development_dependency(%q<hoe>, [">= 1.10.0"])
30
+ else
31
+ s.add_dependency(%q<json>, [">= 1.0.0"])
32
+ s.add_dependency(%q<hoe>, [">= 1.10.0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<json>, [">= 1.0.0"])
36
+ s.add_dependency(%q<hoe>, [">= 1.10.0"])
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ class FacebookGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.file 'config/facebooker.yml', 'config/facebooker.yml'
5
+ m.file 'public/javascripts/facebooker.js', 'public/javascripts/facebooker.js'
6
+ end
7
+ end
8
+
9
+ protected
10
+
11
+ def banner
12
+ "Usage: #{$0} facebooker"
13
+ end
14
+ end
@@ -0,0 +1,46 @@
1
+ # The api key, secret key, and canvas page name are required to get started
2
+ # Tunnel configuration is only needed if you are going to use the facebooker:tunnel Rake tasks
3
+ # Your callback url in Facebook should be set to http://public_host:public_port
4
+ # If you're building a Facebook connect site,
5
+ # change the value of set_asset_host_to_callback_url to false
6
+ # To develop for the new profile design, add the following key..
7
+ # api: new
8
+ # remove the key or set it to anything else to use the old facebook design.
9
+ # This should only be necessary until the final version of the new profile is released.
10
+
11
+ development:
12
+ api_key:
13
+ secret_key:
14
+ canvas_page_name:
15
+ callback_url:
16
+ pretty_errors: true
17
+ set_asset_host_to_callback_url: true
18
+ tunnel:
19
+ public_host_username:
20
+ public_host:
21
+ public_port: 4007
22
+ local_port: 3000
23
+
24
+ test:
25
+ api_key:
26
+ secret_key:
27
+ canvas_page_name:
28
+ callback_url:
29
+ set_asset_host_to_callback_url: true
30
+ tunnel:
31
+ public_host_username:
32
+ public_host:
33
+ public_port: 4007
34
+ local_port: 3000
35
+
36
+ production:
37
+ api_key:
38
+ secret_key:
39
+ canvas_page_name:
40
+ callback_url:
41
+ set_asset_host_to_callback_url: true
42
+ tunnel:
43
+ public_host_username:
44
+ public_host:
45
+ public_port: 4007
46
+ local_port: 3000
@@ -0,0 +1,99 @@
1
+
2
+ function $(element) {
3
+ if (typeof element == "string") {
4
+ element=document.getElementById(element);
5
+ }
6
+ if (element)
7
+ extend_instance(element,Element);
8
+ return element;
9
+ }
10
+
11
+ function extend_instance(instance,hash) {
12
+ for (var name in hash) {
13
+ instance[name] = hash[name];
14
+ }
15
+ }
16
+
17
+ var Element = {
18
+ "hide": function () {
19
+ this.setStyle("display","none")
20
+ },
21
+ "show": function () {
22
+ this.setStyle("display","block")
23
+ },
24
+ "visible": function () {
25
+ return (this.getStyle("display") != "none");
26
+ },
27
+ "toggle": function () {
28
+ if (this.visible) {
29
+ this.hide();
30
+ } else {
31
+ this.show();
32
+ }
33
+ }
34
+ };
35
+
36
+ function encodeURIComponent(str) {
37
+ if (typeof(str) == "string") {
38
+ return str.replace(/=/g,'%3D').replace(/&/g,'%26');
39
+ }
40
+ //checkboxes and radio buttons return objects instead of a string
41
+ else if(typeof(str) == "object"){
42
+ for (prop in str)
43
+ {
44
+ return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
45
+ }
46
+ }
47
+ };
48
+
49
+ var Form = {};
50
+ Form.serialize = function(form_element) {
51
+ return $(form_element).serialize();
52
+ };
53
+
54
+ Ajax.Updater = function (container,url,options) {
55
+ this.container = container;
56
+ this.url=url;
57
+ this.ajax = new Ajax();
58
+ this.ajax.requireLogin = 1;
59
+ if (options["onSuccess"]) {
60
+ this.ajax.responseType = Ajax.JSON;
61
+ this.ajax.ondone = options["onSuccess"];
62
+ } else {
63
+ this.ajax.responseType = Ajax.FBML;
64
+ this.ajax.ondone = function(data) {
65
+ $(container).setInnerFBML(data);
66
+ }
67
+ }
68
+ if (options["onFailure"]) {
69
+ this.ajax.onerror = options["onFailure"];
70
+ }
71
+
72
+ // Yes, this is an excercise in undoing what we just did
73
+ // FB doesn't provide encodeURI, but they will encode things passed as a hash
74
+ // so we turn it into a string, esaping & and =
75
+ // then we split it all back out here
76
+ // this could be killed if encodeURIComponent was available
77
+ parameters={};
78
+ if (options['parameters']) {
79
+ pairs=options['parameters'].split('&');
80
+ for (var i=0; i<pairs.length; i++) {
81
+ kv=pairs[i].split('=');
82
+ key=kv[0].replace(/%3D/g,'=').replace(/%26/g,'&');
83
+ val=kv[1].replace(/%3D/g,'=').replace(/%26/g,'&');
84
+ parameters[key]=val;
85
+ }
86
+ }
87
+ this.ajax.post(url,parameters);
88
+ if (options["onLoading"]) {
89
+ options["onLoading"].call()
90
+ }
91
+ };
92
+ Ajax.Request = function(url,options) {
93
+ Ajax.Updater('unused',url,options);
94
+ };
95
+
96
+ PeriodicalExecuter = function (callback, frequency) {
97
+ setTimeout(callback, frequency *1000);
98
+ setTimeout(function() { new PeriodicalExecuter(callback,frequency); }, frequency*1000);
99
+ };
@@ -0,0 +1,33 @@
1
+ Description:
2
+ Stubs out a new controller and its views. Pass the controller name, either
3
+ CamelCased or under_scored, and a list of views as arguments.
4
+
5
+ To create a controller within a module, specify the controller name as a
6
+ path like 'parent_module/controller_name'.
7
+
8
+ This generates a controller class in app/controllers, view templates in
9
+ app/views/controller_name, a helper class in app/helpers, and a functional
10
+ test suite in test/functional.
11
+
12
+ Also, it generates fbml view templates.
13
+
14
+ Example:
15
+ `./script/generate controller CreditCard open debit credit close`
16
+
17
+ Credit card controller with URLs like /credit_card/debit.
18
+ Controller: app/controllers/credit_card_controller.rb
19
+ Views: app/views/credit_card/debit.html.erb [...],
20
+ app/views/credit_card/debit.fbml.erb [...]
21
+ Helper: app/helpers/credit_card_helper.rb
22
+ Test: test/functional/credit_card_controller_test.rb
23
+
24
+ Modules Example:
25
+ `./script/generate controller 'admin/credit_card' suspend late_fee`
26
+
27
+ Credit card admin controller with URLs /admin/credit_card/suspend.
28
+ Controller: app/controllers/admin/credit_card_controller.rb
29
+ Views: app/views/admin/credit_card/debit.html.erb [...],
30
+ app/views/admin/credit_card/debit.fbml.erb [...]
31
+ Helper: app/helpers/admin/credit_card_helper.rb
32
+ Test: test/functional/admin/credit_card_controller_test.rb
33
+
@@ -0,0 +1,40 @@
1
+ class FacebookControllerGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ # Check for class naming collisions.
5
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
6
+
7
+ # Controller, helper, views, and test directories.
8
+ m.directory File.join('app/controllers', class_path)
9
+ m.directory File.join('app/helpers', class_path)
10
+ m.directory File.join('app/views', class_path, file_name)
11
+ m.directory File.join('test/functional', class_path)
12
+
13
+ # Controller class, functional test, and helper class.
14
+ m.template 'controller.rb',
15
+ File.join('app/controllers',
16
+ class_path,
17
+ "#{file_name}_controller.rb")
18
+
19
+ m.template 'functional_test.rb',
20
+ File.join('test/functional',
21
+ class_path,
22
+ "#{file_name}_controller_test.rb")
23
+
24
+ m.template 'helper.rb',
25
+ File.join('app/helpers',
26
+ class_path,
27
+ "#{file_name}_helper.rb")
28
+
29
+ # View template for each action.
30
+ actions.each do |action|
31
+ html_path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
32
+ m.template 'view.html.erb', html_path,
33
+ :assigns => { :action => action, :path => html_path }
34
+ fbml_path = File.join('app/views', class_path, file_name, "#{action}.fbml.erb")
35
+ m.template 'view.fbml.erb', fbml_path,
36
+ :assigns => { :action => action, :path => fbml_path }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ class <%= class_name %>Controller < ApplicationController
2
+ <% for action in actions -%>
3
+ def <%= action %>
4
+ end
5
+
6
+ <% end -%>
7
+ end