rest-core 0.4.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.travis.yml +2 -7
  2. data/CHANGES.md +13 -2
  3. data/Gemfile +0 -3
  4. data/README.md +30 -34
  5. data/Rakefile +5 -46
  6. data/lib/rest-core.rb +0 -6
  7. data/lib/rest-core/version.rb +1 -1
  8. data/rest-core.gemspec +5 -83
  9. metadata +11 -87
  10. data/example/rails2/Gemfile +0 -21
  11. data/example/rails2/README +0 -4
  12. data/example/rails2/Rakefile +0 -11
  13. data/example/rails2/app/controllers/application_controller.rb +0 -128
  14. data/example/rails2/app/views/application/helper.html.erb +0 -2
  15. data/example/rails2/config/boot.rb +0 -130
  16. data/example/rails2/config/environment.rb +0 -15
  17. data/example/rails2/config/environments/development.rb +0 -17
  18. data/example/rails2/config/environments/production.rb +0 -28
  19. data/example/rails2/config/environments/test.rb +0 -30
  20. data/example/rails2/config/initializers/cookie_verification_secret.rb +0 -7
  21. data/example/rails2/config/initializers/new_rails_defaults.rb +0 -21
  22. data/example/rails2/config/initializers/session_store.rb +0 -15
  23. data/example/rails2/config/preinitializer.rb +0 -23
  24. data/example/rails2/config/rest-core.yaml +0 -16
  25. data/example/rails2/config/routes.rb +0 -43
  26. data/example/rails2/log +0 -0
  27. data/example/rails2/test/functional/application_controller_test.rb +0 -197
  28. data/example/rails2/test/test_helper.rb +0 -18
  29. data/example/rails2/test/unit/rails_util_test.rb +0 -44
  30. data/example/rails3/Gemfile +0 -20
  31. data/example/rails3/README +0 -4
  32. data/example/rails3/Rakefile +0 -7
  33. data/example/rails3/app/controllers/application_controller.rb +0 -128
  34. data/example/rails3/app/views/application/helper.html.erb +0 -2
  35. data/example/rails3/config.ru +0 -4
  36. data/example/rails3/config/application.rb +0 -23
  37. data/example/rails3/config/environment.rb +0 -5
  38. data/example/rails3/config/environments/development.rb +0 -26
  39. data/example/rails3/config/environments/production.rb +0 -49
  40. data/example/rails3/config/environments/test.rb +0 -30
  41. data/example/rails3/config/initializers/secret_token.rb +0 -7
  42. data/example/rails3/config/initializers/session_store.rb +0 -8
  43. data/example/rails3/config/rest-core.yaml +0 -16
  44. data/example/rails3/config/routes.rb +0 -5
  45. data/example/rails3/test/functional/application_controller_test.rb +0 -197
  46. data/example/rails3/test/test_helper.rb +0 -18
  47. data/example/rails3/test/unit/rails_util_test.rb +0 -44
  48. data/example/sinatra/config.ru +0 -16
  49. data/lib/rest-core/client/facebook.rb +0 -251
  50. data/lib/rest-core/client/facebook/rails_util.rb +0 -333
  51. data/lib/rest-core/client/flurry.rb +0 -96
  52. data/lib/rest-core/client/flurry/rails_util.rb +0 -74
  53. data/lib/rest-core/client/github.rb +0 -18
  54. data/lib/rest-core/client/linkedin.rb +0 -59
  55. data/lib/rest-core/client/mixi.rb +0 -47
  56. data/lib/rest-core/client/twitter.rb +0 -101
  57. data/test/client/facebook/config/rest-core.yaml +0 -8
  58. data/test/client/facebook/test_api.rb +0 -97
  59. data/test/client/facebook/test_cache.rb +0 -58
  60. data/test/client/facebook/test_default.rb +0 -23
  61. data/test/client/facebook/test_error.rb +0 -65
  62. data/test/client/facebook/test_handler.rb +0 -84
  63. data/test/client/facebook/test_load_config.rb +0 -39
  64. data/test/client/facebook/test_misc.rb +0 -72
  65. data/test/client/facebook/test_oauth.rb +0 -38
  66. data/test/client/facebook/test_old.rb +0 -114
  67. data/test/client/facebook/test_page.rb +0 -106
  68. data/test/client/facebook/test_parse.rb +0 -128
  69. data/test/client/facebook/test_serialize.rb +0 -43
  70. data/test/client/facebook/test_timeout.rb +0 -22
  71. data/test/client/flurry/test_metrics.rb +0 -83
  72. data/test/client/twitter/test_api.rb +0 -37
@@ -1,21 +0,0 @@
1
-
2
- source 'http://rubygems.org'
3
-
4
- gem 'rails', '2.3.14'
5
-
6
- gem 'rest-client' # for rest-core
7
- gem 'rest-core', :path => '../../'
8
-
9
- group 'test' do
10
- gem 'rr'
11
- gem 'webmock'
12
- end
13
-
14
- platforms(:ruby) do
15
- gem 'yajl-ruby'
16
- end
17
-
18
- platforms(:jruby) do
19
- gem 'json'
20
- gem 'jruby-openssl'
21
- end
@@ -1,4 +0,0 @@
1
-
2
- Please fill config/rest-core.yaml with your app_id, secret, etc., to
3
- see if this example is working or not. The default setup is designed for
4
- standalone site with Facebook JavaScript SDK.
@@ -1,11 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
-
6
- require 'rake/dsl_definition'
7
- require 'rake'
8
- require 'rake/testtask'
9
- require 'rake/rdoctask'
10
-
11
- require 'tasks/rails'
@@ -1,128 +0,0 @@
1
-
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery
4
-
5
- include RestCore::Facebook::RailsUtil
6
- include RestCore::Flurry::RailsUtil
7
-
8
- before_filter :filter_common , :only => [:index]
9
- before_filter :filter_canvas , :only => [:canvas]
10
- before_filter :filter_options , :only => [:options]
11
- before_filter :filter_no_auto , :only => [:no_auto]
12
- before_filter :filter_diff_app_id , :only => [:diff_app_id]
13
- before_filter :filter_diff_canvas , :only => [:diff_canvas]
14
- before_filter :filter_iframe_canvas, :only => [:iframe_canvas]
15
- before_filter :filter_cache , :only => [:cache]
16
- before_filter :filter_hanlder , :only => [:handler_]
17
- before_filter :filter_session , :only => [:session_]
18
- before_filter :filter_cookies , :only => [:cookies_]
19
-
20
- def index
21
- render :text => rc_facebook.get('me').to_json
22
- end
23
- alias_method :canvas , :index
24
- alias_method :options , :index
25
- alias_method :diff_canvas , :index
26
- alias_method :iframe_canvas, :index
27
- alias_method :handler_ , :index
28
- alias_method :session_ , :index
29
- alias_method :cookies_ , :index
30
-
31
- def no_auto
32
- rc_facebook.get('me')
33
- rescue RestCore::Facebook::Error
34
- render :text => 'XD'
35
- end
36
-
37
- def diff_app_id
38
- render :text => rc_facebook.app_id
39
- end
40
-
41
- def cache
42
- url = rc_facebook.url('cache')
43
- rc_facebook.get('cache')
44
- rc_facebook.get('cache')
45
- render :text => Rails.cache.read(Digest::MD5.hexdigest(url))
46
- end
47
-
48
- def error
49
- raise RestCore::Facebook::Error.new("don't rescue me")
50
- end
51
-
52
- def reinitialize
53
- rc_facebook_setup(:cache => {'a' => 'b'})
54
- render :text => YAML.dump(rc_facebook.cache)
55
- end
56
-
57
- def helper; end
58
-
59
- def no_ns_pollution
60
- render :text => Timeout::Error.name
61
- end
62
-
63
- def defaults
64
- rc_facebook_setup
65
- render :text => (rc_facebook.cache == Rails.cache &&
66
- rc_facebook.log_method.receiver == Rails.logger)
67
- end
68
-
69
- private
70
- def filter_common
71
- rc_facebook_setup(:auto_authorize => true, :canvas => '')
72
- end
73
-
74
- def filter_canvas
75
- rc_facebook_setup(:canvas => RestCore::Facebook.
76
- default_canvas,
77
- :auto_authorize_scope => 'publish_stream')
78
- end
79
-
80
- def filter_diff_canvas
81
- rc_facebook_setup(:canvas => 'ToT',
82
- :auto_authorize_scope => 'email')
83
- end
84
-
85
- def filter_iframe_canvas
86
- rc_facebook_setup(:canvas => 'zzz',
87
- :auto_authorize => true)
88
- end
89
-
90
- def filter_no_auto
91
- rc_facebook_setup(:auto_authorize => false)
92
- end
93
-
94
- def filter_diff_app_id
95
- rc_facebook_setup(:app_id => 'zzz',
96
- :auto_authorize => true)
97
- end
98
-
99
- def filter_options
100
- rc_facebook_setup(:auto_authorize_options => {:scope => 'bogus'},
101
- :canvas => nil)
102
- end
103
-
104
- def filter_cache
105
- rc_facebook_setup(:cache => Rails.cache)
106
- end
107
-
108
- def filter_hanlder
109
- rc_facebook_setup(:write_handler => method(:write_handler),
110
- :check_handler => method(:check_handler))
111
- end
112
-
113
- def write_handler fbs
114
- Rails.cache[:fbs] = fbs
115
- end
116
-
117
- def check_handler
118
- Rails.cache[:fbs]
119
- end
120
-
121
- def filter_session
122
- rc_facebook_setup(:write_session => true)
123
- end
124
-
125
- def filter_cookies
126
- rc_facebook_setup(:write_cookies => true)
127
- end
128
- end
@@ -1,2 +0,0 @@
1
- <%= rc_facebook.app_id %>
2
- <%= rc_flurry .api_key %>
@@ -1,130 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- if load_error.message =~ /Could not find RubyGem rails/
66
- STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
67
- exit 1
68
- else
69
- raise
70
- end
71
- end
72
-
73
- class << self
74
- def rubygems_version
75
- Gem::RubyGemsVersion rescue nil
76
- end
77
-
78
- def gem_version
79
- if defined? RAILS_GEM_VERSION
80
- RAILS_GEM_VERSION
81
- elsif ENV.include?('RAILS_GEM_VERSION')
82
- ENV['RAILS_GEM_VERSION']
83
- else
84
- parse_gem_version(read_environment_rb)
85
- end
86
- end
87
-
88
- def load_rubygems
89
- min_version = '1.3.2'
90
- require 'rubygems'
91
- unless rubygems_version >= min_version
92
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
93
- exit 1
94
- end
95
-
96
- rescue LoadError
97
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
98
- exit 1
99
- end
100
-
101
- def parse_gem_version(text)
102
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
103
- end
104
-
105
- private
106
- def read_environment_rb
107
- File.read("#{RAILS_ROOT}/config/environment.rb")
108
- end
109
- end
110
- end
111
- end
112
-
113
- # begin copied from http://gembundler.com/rails23.html
114
- class Rails::Boot
115
- def run
116
- load_initializer
117
-
118
- Rails::Initializer.class_eval do
119
- def load_gems
120
- @bundler_loaded ||= Bundler.require(:default, Rails.env.to_sym)
121
- end
122
- end
123
-
124
- Rails::Initializer.run(:set_load_path)
125
- end
126
- end
127
- # end copied from http://gembundler.com/rails23.html
128
-
129
- # All that for this:
130
- Rails.boot!
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file
2
-
3
- # Specifies gem version of Rails to use when vendor/rails is not present
4
- RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
5
-
6
- # Bootstrap the Rails environment, frameworks, and default configuration
7
- require File.join(File.dirname(__FILE__), 'boot')
8
-
9
- Rails::Initializer.run do |config|
10
- # we use bundler now, so don't do this at this example
11
- # config.gem 'rest-graph'
12
-
13
- config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
14
- config.time_zone = 'UTC'
15
- end
@@ -1,17 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # In the development environment your application's code is reloaded on
4
- # every request. This slows down response time but is perfect for development
5
- # since you don't have to restart the webserver when you make code changes.
6
- config.cache_classes = false
7
-
8
- # Log error messages when you accidentally call methods on nil.
9
- config.whiny_nils = true
10
-
11
- # Show full error reports and disable caching
12
- config.action_controller.consider_all_requests_local = true
13
- config.action_view.debug_rjs = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
@@ -1,28 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The production environment is meant for finished, "live" apps.
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.action_controller.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
- config.action_view.cache_template_loading = true
11
-
12
- # See everything in the log (default is :info)
13
- # config.log_level = :debug
14
-
15
- # Use a different logger for distributed setups
16
- # config.logger = SyslogLogger.new
17
-
18
- # Use a different cache store in production
19
- # config.cache_store = :mem_cache_store
20
-
21
- # Enable serving of images, stylesheets, and javascripts from an asset server
22
- # config.action_controller.asset_host = "http://assets.example.com"
23
-
24
- # Disable delivery errors, bad email addresses will be ignored
25
- # config.action_mailer.raise_delivery_errors = false
26
-
27
- # Enable threaded mode
28
- # config.threadsafe!
@@ -1,30 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
- config.action_view.cache_template_loading = true
16
-
17
- # Disable request forgery protection in test environment
18
- config.action_controller.allow_forgery_protection = false
19
-
20
- # Tell Action Mailer not to deliver emails to the real world.
21
- # The :test delivery method accumulates sent emails in the
22
- # ActionMailer::Base.deliveries array.
23
- config.action_mailer.delivery_method = :test
24
-
25
- # Use SQL instead of Active Record's schema dumper when creating the test database.
26
- # This is necessary if your schema can't be completely dumped by the schema dumper,
27
- # like if you have constraints or database-specific column types
28
- # config.active_record.schema_format = :sql
29
-
30
- config.logger = Logger.new($stdout, :debug)
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- ActionController::Base.cookie_verifier_secret = '095e8e5c0b6b901901efb23fab50005b68d9d6a9d41f4ec780946cff34b26603762bc0ea1baf204613b252e5ae499d38b232d5b75edac513a723e450e76548a3';
@@ -1,21 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # These settings change the behavior of Rails 2 apps and will be defaults
4
- # for Rails 3. You can remove this initializer when Rails 3 is released.
5
-
6
- if defined?(ActiveRecord)
7
- # Include Active Record class name as root for JSON serialized output.
8
- ActiveRecord::Base.include_root_in_json = true
9
-
10
- # Store the full class name (including module namespace) in STI type column.
11
- ActiveRecord::Base.store_full_sti_class = true
12
- end
13
-
14
- ActionController::Routing.generate_best_match = false
15
-
16
- # Use ISO 8601 format for JSON serialized times and dates.
17
- ActiveSupport.use_standard_json_time_format = true
18
-
19
- # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
- # if you're including raw json in an HTML page.
21
- ActiveSupport.escape_html_entities_in_json = false
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying cookie session data integrity.
4
- # If you change this key, all old sessions will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- ActionController::Base.session = {
8
- :key => '_rails2_session',
9
- :secret => 'c99a19ce0dc4ed1809e32b6b43bd9229c3a504c456230119dd445fdcb63c0ce06b436f1bf1eace27ebbe0da6041ff2b65cbb4ae4beadc3077e3e6ae07ea75118'
10
- }
11
-
12
- # Use the database for sessions instead of the cookie-based default,
13
- # which shouldn't be used to store highly confidential information
14
- # (create the session table with "rake db:sessions:create")
15
- # ActionController::Base.session_store = :active_record_store