corey-facebooker 1.0.28.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/COPYING.rdoc +19 -0
  3. data/README.rdoc +104 -0
  4. data/Rakefile +86 -0
  5. data/TODO.rdoc +4 -0
  6. data/generators/facebook/facebook_generator.rb +14 -0
  7. data/generators/facebook/templates/config/facebooker.yml +49 -0
  8. data/generators/facebook/templates/public/javascripts/facebooker.js +99 -0
  9. data/generators/facebook_controller/USAGE +33 -0
  10. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  11. data/generators/facebook_controller/templates/controller.rb +7 -0
  12. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  13. data/generators/facebook_controller/templates/helper.rb +2 -0
  14. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  15. data/generators/facebook_controller/templates/view.html.erb +2 -0
  16. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  17. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  18. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  19. data/generators/facebook_scaffold/USAGE +27 -0
  20. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  21. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  22. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  23. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  24. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  25. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  26. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  27. data/generators/facebook_scaffold/templates/style.css +74 -0
  28. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  29. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  30. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  31. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  32. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  33. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  34. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  35. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  36. data/generators/publisher/publisher_generator.rb +14 -0
  37. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  38. data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
  39. data/init.rb +23 -0
  40. data/install.rb +12 -0
  41. data/lib/facebooker.rb +181 -0
  42. data/lib/facebooker/adapters/adapter_base.rb +90 -0
  43. data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
  44. data/lib/facebooker/adapters/facebook_adapter.rb +52 -0
  45. data/lib/facebooker/admin.rb +42 -0
  46. data/lib/facebooker/batch_request.rb +44 -0
  47. data/lib/facebooker/data.rb +57 -0
  48. data/lib/facebooker/feed.rb +78 -0
  49. data/lib/facebooker/logging.rb +51 -0
  50. data/lib/facebooker/mobile.rb +20 -0
  51. data/lib/facebooker/mock/service.rb +50 -0
  52. data/lib/facebooker/mock/session.rb +18 -0
  53. data/lib/facebooker/model.rb +137 -0
  54. data/lib/facebooker/models/affiliation.rb +10 -0
  55. data/lib/facebooker/models/album.rb +11 -0
  56. data/lib/facebooker/models/applicationproperties.rb +39 -0
  57. data/lib/facebooker/models/applicationrestrictions.rb +10 -0
  58. data/lib/facebooker/models/cookie.rb +10 -0
  59. data/lib/facebooker/models/education_info.rb +11 -0
  60. data/lib/facebooker/models/event.rb +28 -0
  61. data/lib/facebooker/models/friend_list.rb +16 -0
  62. data/lib/facebooker/models/group.rb +36 -0
  63. data/lib/facebooker/models/info_item.rb +10 -0
  64. data/lib/facebooker/models/info_section.rb +10 -0
  65. data/lib/facebooker/models/location.rb +8 -0
  66. data/lib/facebooker/models/notifications.rb +17 -0
  67. data/lib/facebooker/models/page.rb +27 -0
  68. data/lib/facebooker/models/photo.rb +12 -0
  69. data/lib/facebooker/models/tag.rb +12 -0
  70. data/lib/facebooker/models/user.rb +471 -0
  71. data/lib/facebooker/models/video.rb +9 -0
  72. data/lib/facebooker/models/work_info.rb +9 -0
  73. data/lib/facebooker/parser.rb +610 -0
  74. data/lib/facebooker/rails/controller.rb +307 -0
  75. data/lib/facebooker/rails/cucumber.rb +28 -0
  76. data/lib/facebooker/rails/cucumber/world.rb +46 -0
  77. data/lib/facebooker/rails/extensions/action_controller.rb +48 -0
  78. data/lib/facebooker/rails/extensions/rack_setup.rb +2 -0
  79. data/lib/facebooker/rails/extensions/routing.rb +15 -0
  80. data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
  81. data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
  82. data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
  83. data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
  84. data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
  85. data/lib/facebooker/rails/facebook_url_rewriting.rb +52 -0
  86. data/lib/facebooker/rails/helpers.rb +772 -0
  87. data/lib/facebooker/rails/helpers/fb_connect.rb +99 -0
  88. data/lib/facebooker/rails/integration_session.rb +38 -0
  89. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  90. data/lib/facebooker/rails/publisher.rb +530 -0
  91. data/lib/facebooker/rails/routing.rb +49 -0
  92. data/lib/facebooker/rails/test_helpers.rb +68 -0
  93. data/lib/facebooker/rails/utilities.rb +22 -0
  94. data/lib/facebooker/server_cache.rb +24 -0
  95. data/lib/facebooker/service.rb +94 -0
  96. data/lib/facebooker/session.rb +596 -0
  97. data/lib/facebooker/version.rb +9 -0
  98. data/lib/net/http_multipart_post.rb +123 -0
  99. data/lib/rack/facebook.rb +77 -0
  100. data/lib/tasks/facebooker.rake +18 -0
  101. data/lib/tasks/tunnel.rake +46 -0
  102. data/rails/init.rb +1 -0
  103. data/setup.rb +1585 -0
  104. data/templates/layout.erb +24 -0
  105. data/test/facebooker/adapters_test.rb +96 -0
  106. data/test/facebooker/admin_test.rb +102 -0
  107. data/test/facebooker/batch_request_test.rb +83 -0
  108. data/test/facebooker/data_test.rb +86 -0
  109. data/test/facebooker/logging_test.rb +43 -0
  110. data/test/facebooker/mobile_test.rb +45 -0
  111. data/test/facebooker/model_test.rb +123 -0
  112. data/test/facebooker/models/event_test.rb +15 -0
  113. data/test/facebooker/models/user_test.rb +331 -0
  114. data/test/facebooker/rails/publisher_test.rb +468 -0
  115. data/test/facebooker/rails_integration_test.rb +1349 -0
  116. data/test/facebooker/server_cache_test.rb +44 -0
  117. data/test/facebooker/session_test.rb +614 -0
  118. data/test/facebooker_test.rb +925 -0
  119. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  120. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  121. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  122. data/test/net/http_multipart_post_test.rb +52 -0
  123. data/test/rack/facebook_test.rb +62 -0
  124. data/test/rails_test_helper.rb +13 -0
  125. data/test/test_helper.rb +66 -0
  126. metadata +219 -0
@@ -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
@@ -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.
@@ -0,0 +1,104 @@
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
+ {Join the Mailing List}:[groups.google.com/group/facebooker]
26
+
27
+ == REQUIREMENTS:
28
+
29
+ None
30
+
31
+ == INSTALL:
32
+
33
+ === Non Rails
34
+
35
+ The best way is:
36
+
37
+ gem install facebooker
38
+
39
+ If, for some reason, you can't/won't use RubyGems, you can do:
40
+
41
+ (sudo) ruby setup.rb
42
+
43
+ === Rails
44
+
45
+ Facebooker can be installed as a Rails plugin by:
46
+
47
+ script/plugin install git://github.com/mmangino/facebooker.git
48
+
49
+ If you don't have git, the plugin can be downloaded from http://github.com/mmangino/facebooker/tarball/master
50
+
51
+ Once the plugin is installed, you will need to configure your Facebook app in config/facebooker.yml.
52
+
53
+ Your application users will need to have added the application in facebook to access all of facebooker's features. You enforce this by adding
54
+
55
+ ensure_application_is_installed_by_facebook_user
56
+
57
+ to your application controller.
58
+
59
+ == using MemCache session
60
+
61
+ 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:
62
+
63
+ # add - as an okay key
64
+ class CGI
65
+ class Session
66
+ class MemCacheStore
67
+ def check_id(id) #:nodoc:#
68
+ /[^0-9a-zA-Z\-\._]+/ =~ id.to_s ? false : true
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+
75
+ == LICENSE:
76
+
77
+ (The MIT License)
78
+
79
+ Copyright (c) 2008-2009:
80
+
81
+ * Chad Fowler
82
+ * Patrick Ewing
83
+ * Mike Mangino
84
+ * Shane Vitarana
85
+ * Corey Innis
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining
88
+ a copy of this software and associated documentation files (the
89
+ 'Software'), to deal in the Software without restriction, including
90
+ without limitation the rights to use, copy, modify, merge, publish,
91
+ distribute, sublicense, and/or sell copies of the Software, and to
92
+ permit persons to whom the Software is furnished to do so, subject to
93
+ the following conditions:
94
+
95
+ The above copyright notice and this permission notice shall be
96
+ included in all copies or substantial portions of the Software.
97
+
98
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
99
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
100
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
101
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
102
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
103
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
104
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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
@@ -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
+ 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,49 @@
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
+ server_alive_interval: 0
24
+
25
+ test:
26
+ api_key:
27
+ secret_key:
28
+ canvas_page_name:
29
+ callback_url:
30
+ set_asset_host_to_callback_url: true
31
+ tunnel:
32
+ public_host_username:
33
+ public_host:
34
+ public_port: 4007
35
+ local_port: 3000
36
+ server_alive_interval: 0
37
+
38
+ production:
39
+ api_key:
40
+ secret_key:
41
+ canvas_page_name:
42
+ callback_url:
43
+ set_asset_host_to_callback_url: true
44
+ tunnel:
45
+ public_host_username:
46
+ public_host:
47
+ public_port: 4007
48
+ local_port: 3000
49
+ server_alive_interval: 0
@@ -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