wrest 0.0.8 → 0.0.9
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/README.rdoc +24 -17
- data/Rakefile +5 -4
- data/VERSION.yml +1 -1
- data/examples/delicious.rb +7 -3
- data/examples/redirection.rb +27 -0
- data/examples/twitter.rb +78 -0
- data/{spec/wrest/http/request_spec.rb → examples/twitter_public_timeline.rb} +15 -12
- data/examples/wow_realm_status.rb +7 -3
- data/lib/wrest/components/attributes_container/alias_accessors.rb +66 -0
- data/lib/wrest/components/attributes_container/typecaster.rb +44 -38
- data/lib/wrest/components/attributes_container.rb +23 -5
- data/lib/wrest/components/mutators/base.rb +1 -1
- data/lib/wrest/components/translators.rb +1 -1
- data/lib/wrest/core_ext/string/conversions.rb +1 -1
- data/lib/wrest/exceptions.rb +14 -2
- data/lib/wrest/http/get.rb +2 -0
- data/lib/wrest/http/redirection.rb +35 -0
- data/lib/wrest/http/request.rb +37 -13
- data/lib/wrest/http/response.rb +17 -0
- data/lib/wrest/http.rb +1 -0
- data/lib/wrest/resource/base.rb +1 -2
- data/lib/wrest/uri.rb +2 -0
- data/lib/wrest/version.rb +1 -1
- data/spec/functional/sample_rails_app/README +3 -0
- data/spec/functional/sample_rails_app/Rakefile +10 -0
- data/spec/functional/sample_rails_app/app/controllers/application_controller.rb +10 -0
- data/spec/functional/sample_rails_app/app/controllers/lead_bottles_controller.rb +7 -0
- data/spec/functional/sample_rails_app/app/helpers/application_helper.rb +3 -0
- data/spec/functional/sample_rails_app/app/models/bottle.rb +3 -0
- data/spec/functional/sample_rails_app/app/models/glass_bottle.rb +3 -0
- data/spec/functional/sample_rails_app/app/models/lead_bottle.rb +3 -0
- data/spec/functional/sample_rails_app/config/boot.rb +110 -0
- data/spec/functional/sample_rails_app/config/database.yml +16 -0
- data/spec/functional/sample_rails_app/config/environment.rb +42 -0
- data/spec/functional/sample_rails_app/config/environments/development.rb +17 -0
- data/spec/functional/sample_rails_app/config/environments/production.rb +28 -0
- data/spec/functional/sample_rails_app/config/environments/test.rb +28 -0
- data/spec/functional/sample_rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/functional/sample_rails_app/config/initializers/inflections.rb +10 -0
- data/spec/functional/sample_rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/functional/sample_rails_app/config/initializers/new_rails_defaults.rb +19 -0
- data/spec/functional/sample_rails_app/config/initializers/session_store.rb +15 -0
- data/spec/functional/sample_rails_app/config/locales/en.yml +5 -0
- data/spec/functional/sample_rails_app/config/routes.rb +3 -0
- data/spec/functional/sample_rails_app/db/development.sqlite3 +0 -0
- data/spec/functional/sample_rails_app/db/migrate/20090319115628_create_bottle.rb +13 -0
- data/spec/functional/sample_rails_app/db/schema.rb +20 -0
- data/spec/functional/sample_rails_app/db/test.sqlite3 +0 -0
- data/spec/functional/sample_rails_app/log/development.log +1 -0
- data/spec/functional/sample_rails_app/public/404.html +30 -0
- data/spec/functional/sample_rails_app/public/422.html +30 -0
- data/spec/functional/sample_rails_app/public/500.html +30 -0
- data/spec/functional/sample_rails_app/public/favicon.ico +0 -0
- data/spec/functional/sample_rails_app/public/images/rails.png +0 -0
- data/spec/functional/sample_rails_app/public/index.html +275 -0
- data/spec/functional/sample_rails_app/public/robots.txt +5 -0
- data/spec/functional/sample_rails_app/script/about +4 -0
- data/spec/functional/sample_rails_app/script/autospec +6 -0
- data/spec/functional/sample_rails_app/script/console +3 -0
- data/spec/functional/sample_rails_app/script/dbconsole +3 -0
- data/spec/functional/sample_rails_app/script/destroy +3 -0
- data/spec/functional/sample_rails_app/script/generate +3 -0
- data/spec/functional/sample_rails_app/script/performance/benchmarker +3 -0
- data/spec/functional/sample_rails_app/script/performance/profiler +3 -0
- data/spec/functional/sample_rails_app/script/plugin +3 -0
- data/spec/functional/sample_rails_app/script/runner +3 -0
- data/spec/functional/sample_rails_app/script/server +3 -0
- data/spec/functional/sample_rails_app/script/spec +10 -0
- data/spec/functional/sample_rails_app/script/spec_server +9 -0
- data/spec/functional/sample_rails_app/test/performance/browsing_test.rb +9 -0
- data/spec/functional/sample_rails_app/test/test_helper.rb +38 -0
- data/spec/functional/sample_rails_app/tmtags +2559 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/MIT-LICENSE +20 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/README.rdoc +100 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/Rakefile +18 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/init.rb +5 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/install.rb +1 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/base.rb +140 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/controllers/resources.rb +16 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/controllers/resources_controller.rb +26 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/controllers/routes_controller.rb +16 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/core_extensions/api.rb +26 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/core_extensions/exception.rb +23 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/core_extensions/from_json.rb +15 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/dispatch.rb +235 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/models/resourced_route.rb +84 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/query.rb +337 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/render/html.rb +50 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/render/json.rb +75 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/render/xml.rb +65 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/render.rb +63 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/retrieve.rb +74 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full/version.rb +9 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/lib/resource_full.rb +14 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/base_spec.rb +88 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/controllers/resources_spec.rb +29 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/dispatch_spec.rb +262 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/models/resourced_route_spec.rb +62 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/query/parameter_spec.rb +57 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/query_spec.rb +462 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/render/html_spec.rb +4 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/render/json_spec.rb +107 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/render/xml_spec.rb +98 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/render_spec.rb +5 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/resource_full/retrieve_spec.rb +173 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/spec/spec_helper.rb +98 -0
- data/spec/functional/sample_rails_app/vendor/plugins/resource_full/uninstall.rb +1 -0
- data/spec/functional/spec_helper.rb +0 -0
- data/spec/{spec_helper.rb → unit/spec_helper.rb} +2 -2
- data/spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb +49 -0
- data/spec/{wrest → unit/wrest}/components/attributes_container/typecaster_spec.rb +28 -8
- data/spec/{wrest → unit/wrest}/components/attributes_container_spec.rb +42 -15
- data/spec/{wrest → unit/wrest}/components/mutators/base_spec.rb +1 -1
- data/spec/{wrest → unit/wrest}/components/mutators/camel_to_snake_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/components/mutators/xml_mini_type_caster_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/components/mutators/xml_simple_type_caster_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/components/mutators_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/components/translators/xml_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/components/translators_spec.rb +1 -1
- data/spec/{wrest → unit/wrest}/core_ext/hash/conversions_spec.rb +0 -0
- data/spec/{wrest → unit/wrest}/core_ext/string/conversions_spec.rb +14 -0
- data/spec/unit/wrest/http/redirection_spec.rb +42 -0
- data/spec/unit/wrest/http/request_spec.rb +70 -0
- data/spec/unit/wrest/http/response_spec.rb +45 -0
- data/spec/{wrest → unit/wrest}/resource/base_spec.rb +5 -4
- data/spec/{wrest → unit/wrest}/uri_spec.rb +68 -67
- data/spec/{wrest → unit/wrest}/uri_template_spec.rb +0 -0
- metadata +187 -38
- data/lib/wrest/exceptions/method_not_overridden_exception.rb +0 -17
- data/lib/wrest/exceptions/unsupported_content_type_exception.rb +0 -17
- data/spec/wrest/http/response_spec.rb +0 -21
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Copyright 2009 Sidu Ponnappa
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at Http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
7
|
+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
|
9
|
+
|
|
10
|
+
module Wrest #:nodoc:
|
|
11
|
+
module Http #:nodoc:
|
|
12
|
+
# Constructed by Wrest::Response.new if the HTTP response code is 3xx
|
|
13
|
+
# (http://en.wikipedia.org/wiki/300_Multiple_Choices#3xx_Redirection)
|
|
14
|
+
class Redirection < Response
|
|
15
|
+
|
|
16
|
+
# A get is invoked on the url stored in the response headers
|
|
17
|
+
# under the key 'location' and the new Response is returned.
|
|
18
|
+
#
|
|
19
|
+
# The follow_redirects_count and follow_redirects_limit options
|
|
20
|
+
# should be present. follow_redirects_count will be incremented by 1.
|
|
21
|
+
#
|
|
22
|
+
# This method will raise a Wrest::Exceptions::AutoRedirectLimitExceeded
|
|
23
|
+
# if the follow_redirects_count equals the follow_redirects_limit.
|
|
24
|
+
def follow(redirect_request_options = {})
|
|
25
|
+
target = self['location']
|
|
26
|
+
redirect_request_options = redirect_request_options.clone
|
|
27
|
+
|
|
28
|
+
raise Wrest::Exceptions::AutoRedirectLimitExceeded if (redirect_request_options[:follow_redirects_count] += 1) >= redirect_request_options[:follow_redirects_limit]
|
|
29
|
+
|
|
30
|
+
Wrest.logger.debug "--| Redirecting to #{target}"
|
|
31
|
+
target.to_uri(redirect_request_options).get
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/wrest/http/request.rb
CHANGED
|
@@ -8,16 +8,39 @@
|
|
|
8
8
|
# See the License for the specific language governing permissions and limitations under the License.
|
|
9
9
|
|
|
10
10
|
module Wrest::Http
|
|
11
|
+
# This represents a HTTP request. Typically you will never need to instantiate
|
|
12
|
+
# one of these yourself - you can use one of the more conveient APIs via Wrest::Uri
|
|
13
|
+
# or Wrest::Http::Get etc. instead.
|
|
11
14
|
class Request
|
|
12
|
-
attr_reader :http_request, :uri, :body, :headers, :username, :password
|
|
15
|
+
attr_reader :http_request, :uri, :body, :headers, :username, :password, :follow_redirects,
|
|
16
|
+
:follow_redirects_limit, :follow_redirects_count, :timeout
|
|
17
|
+
# Valid tuples for the options are:
|
|
18
|
+
# :username => String, defaults to nil
|
|
19
|
+
# :password => String, defaults to nil
|
|
20
|
+
# :follow_redirects => Boolean, defaults to true for Get, false for anything else
|
|
21
|
+
# :follow_redirects_limit => Integer, defaults to 5. This is the number of redirects
|
|
22
|
+
# that Wrest will automatically follow before raising an
|
|
23
|
+
# Wrest::Exceptions::AutoRedirectLimitExceeded exception.
|
|
24
|
+
# For example, if you set this to 1, the very first redirect
|
|
25
|
+
# will raise the exception.
|
|
26
|
+
# :follow_redirects_count => Integer, defaults to 0. This is a count of the hops made to
|
|
27
|
+
# get to this request and increases by one for every redirect
|
|
28
|
+
# until the follow_redirects_limit is hit. You should never set
|
|
29
|
+
# this option yourself.
|
|
30
|
+
# :timeout => The period, in seconds, after which a Timeout::Error is raised
|
|
31
|
+
# in the event of a connection failing to open. Defaults to 60.
|
|
13
32
|
def initialize(wrest_uri, http_request_klass, parameters = {}, body = nil, headers = {}, options = {})
|
|
14
33
|
@uri = wrest_uri
|
|
15
34
|
@headers = headers.stringify_keys
|
|
16
35
|
@http_request = http_request_klass.new(parameters.empty? ? wrest_uri.full_path : "#{wrest_uri.full_path}?#{parameters.to_query}", @headers)
|
|
17
36
|
@body = body
|
|
18
|
-
@options = options
|
|
19
|
-
@username = options[:username]
|
|
20
|
-
@password = options[:password]
|
|
37
|
+
@options = options.clone
|
|
38
|
+
@username = @options[:username]
|
|
39
|
+
@password = @options[:password]
|
|
40
|
+
@follow_redirects = (@options[:follow_redirects] ||= false)
|
|
41
|
+
@follow_redirects_count = (@options[:follow_redirects_count] ||= 0)
|
|
42
|
+
@follow_redirects_limit = (@options[:follow_redirects_limit] ||= 5)
|
|
43
|
+
@timeout = (@options[:timeout] ||= 60)
|
|
21
44
|
end
|
|
22
45
|
|
|
23
46
|
# Makes a request and returns a Wrest::Http::Response.
|
|
@@ -26,23 +49,24 @@ module Wrest::Http
|
|
|
26
49
|
response = nil
|
|
27
50
|
|
|
28
51
|
prefix = "#{http_request.method} #{http_request.hash}"
|
|
29
|
-
|
|
52
|
+
http_connection = create_connection(timeout)
|
|
53
|
+
http_request.basic_auth username, password
|
|
30
54
|
|
|
31
55
|
Wrest.logger.debug "--> (#{prefix}) #{@uri.protocol}://#{@uri.host}:#{@uri.port}#{@http_request.path}"
|
|
32
|
-
time = Benchmark.realtime { response = Wrest::Http::Response.new(
|
|
56
|
+
time = Benchmark.realtime { response = Wrest::Http::Response.new( http_connection.request(@http_request, @body) ) }
|
|
33
57
|
Wrest.logger.debug "<-- (#{prefix}) %d %s (%d bytes %.2fs)" % [response.code, response.message, response.body ? response.body.length : 0, time]
|
|
34
58
|
|
|
35
|
-
response
|
|
59
|
+
@follow_redirects ? response.follow(@options) : response
|
|
36
60
|
end
|
|
37
61
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
def create_connection(timeout)
|
|
63
|
+
connection = Net::HTTP.new(@uri.host, @uri.port)
|
|
64
|
+
connection.read_timeout = timeout
|
|
41
65
|
if @uri.https?
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
connection.use_ssl = true
|
|
67
|
+
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
44
68
|
end
|
|
45
|
-
|
|
69
|
+
connection
|
|
46
70
|
end
|
|
47
71
|
end
|
|
48
72
|
end
|
data/lib/wrest/http/response.rb
CHANGED
|
@@ -24,6 +24,14 @@ module Wrest #:nodoc:
|
|
|
24
24
|
:[], :content_length, :content_type, :each_header, :each_name, :each_value, :fetch,
|
|
25
25
|
:get_fields, :key?, :type_params
|
|
26
26
|
|
|
27
|
+
# We're overriding :new to act as a factory so
|
|
28
|
+
# we can build the appropriate Response instance
|
|
29
|
+
def self.new(http_response)
|
|
30
|
+
instance = ((300..399).include?(http_response.code.to_i) ? Wrest::Http::Redirection : self).allocate
|
|
31
|
+
instance.send :initialize, http_response
|
|
32
|
+
instance
|
|
33
|
+
end
|
|
34
|
+
|
|
27
35
|
def initialize(http_response)
|
|
28
36
|
@http_response = http_response
|
|
29
37
|
end
|
|
@@ -39,6 +47,15 @@ module Wrest #:nodoc:
|
|
|
39
47
|
def headers
|
|
40
48
|
@http_response.to_hash
|
|
41
49
|
end
|
|
50
|
+
|
|
51
|
+
# A null object implementation - invoking this method on
|
|
52
|
+
# a response simply returns the same response unless
|
|
53
|
+
# the response is a Redirection (code 3xx), in which case a
|
|
54
|
+
# get is invoked on the url stored in the response headers
|
|
55
|
+
# under the key 'location' and the new Response is returned.
|
|
56
|
+
def follow(redirect_request_options = {})
|
|
57
|
+
self
|
|
58
|
+
end
|
|
42
59
|
end
|
|
43
60
|
end
|
|
44
61
|
end
|
data/lib/wrest/http.rb
CHANGED
data/lib/wrest/resource/base.rb
CHANGED
|
@@ -12,7 +12,6 @@ module Wrest::Resource #:nodoc:
|
|
|
12
12
|
# It is a REST client targetted at Rails REST apps.
|
|
13
13
|
class Base
|
|
14
14
|
include Wrest::Components::AttributesContainer
|
|
15
|
-
include Wrest::Components::AttributesContainer::Typecaster
|
|
16
15
|
|
|
17
16
|
always_has :id
|
|
18
17
|
typecast :id => as_integer
|
|
@@ -43,7 +42,7 @@ module Wrest::Resource #:nodoc:
|
|
|
43
42
|
# we often do while writing tests.
|
|
44
43
|
# By default, the resource name is set to the name of the class.
|
|
45
44
|
def set_resource_name(resource_name)
|
|
46
|
-
self.class_eval "def self.resource_name; '#{resource_name.underscore}';end"
|
|
45
|
+
self.class_eval "def self.resource_name; '#{resource_name.to_s.underscore}';end"
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
# Allows the host url at which the resource is found to be configured
|
data/lib/wrest/uri.rb
CHANGED
|
@@ -23,6 +23,8 @@ module Wrest #:nodoc:
|
|
|
23
23
|
# You can find examples that use real APIs (like delicious) under the wrest/examples directory.
|
|
24
24
|
class Uri
|
|
25
25
|
attr_reader :uri, :username, :password
|
|
26
|
+
|
|
27
|
+
# See Wrest::Http::Request for the available options and their default values.
|
|
26
28
|
def initialize(uri_string, options = {})
|
|
27
29
|
@options = options
|
|
28
30
|
@uri_string = uri_string.clone
|
data/lib/wrest/version.rb
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
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'
|
|
7
|
+
require 'rake/testtask'
|
|
8
|
+
require 'rake/rdoctask'
|
|
9
|
+
|
|
10
|
+
require 'tasks/rails'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
|
3
|
+
|
|
4
|
+
class ApplicationController < ActionController::Base
|
|
5
|
+
helper :all # include all helpers, all the time
|
|
6
|
+
# protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
|
7
|
+
# session :off
|
|
8
|
+
# Scrub sensitive parameters from your log
|
|
9
|
+
# filter_parameter_logging :password
|
|
10
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
$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.)
|
|
66
|
+
exit 1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class << self
|
|
70
|
+
def rubygems_version
|
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def gem_version
|
|
75
|
+
if defined? RAILS_GEM_VERSION
|
|
76
|
+
RAILS_GEM_VERSION
|
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
|
79
|
+
else
|
|
80
|
+
parse_gem_version(read_environment_rb)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def load_rubygems
|
|
85
|
+
require 'rubygems'
|
|
86
|
+
min_version = '1.3.1'
|
|
87
|
+
unless rubygems_version >= min_version
|
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
|
89
|
+
exit 1
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
rescue LoadError
|
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
|
94
|
+
exit 1
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def parse_gem_version(text)
|
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
def read_environment_rb
|
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# All that for this:
|
|
110
|
+
Rails.boot!
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
|
3
|
+
development:
|
|
4
|
+
adapter: sqlite3
|
|
5
|
+
database: "db/development.sqlite3"
|
|
6
|
+
pool: 5
|
|
7
|
+
timeout: 5000
|
|
8
|
+
|
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
|
10
|
+
# re-generated from your development database when you run "rake".
|
|
11
|
+
# Do not set this db to the same as development or production.
|
|
12
|
+
test:
|
|
13
|
+
adapter: sqlite3
|
|
14
|
+
database: db/test.sqlite3
|
|
15
|
+
pool: 5
|
|
16
|
+
timeout: 5000
|
|
@@ -0,0 +1,42 @@
|
|
|
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.2' 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
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
+
# Application configuration should go into files in config/initializers
|
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
+
|
|
14
|
+
# Add additional load paths for your own custom dirs
|
|
15
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
|
16
|
+
|
|
17
|
+
# Specify gems that this application depends on and have them installed with rake gems:install
|
|
18
|
+
# config.gem "bj"
|
|
19
|
+
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
|
20
|
+
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
|
21
|
+
# config.gem "aws-s3", :lib => "aws/s3"
|
|
22
|
+
|
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
26
|
+
|
|
27
|
+
# Skip frameworks you're not going to use. To use Rails without a database,
|
|
28
|
+
# you must remove the Active Record framework.
|
|
29
|
+
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
|
30
|
+
|
|
31
|
+
# Activate observers that should always be running
|
|
32
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
33
|
+
|
|
34
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
35
|
+
# Run "rake -D time" for a list of tasks for finding time zone names.
|
|
36
|
+
config.time_zone = 'UTC'
|
|
37
|
+
|
|
38
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
39
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
|
40
|
+
# config.i18n.default_locale = :de
|
|
41
|
+
end
|
|
42
|
+
# Wrest.logger = ActiveRecord::Base.logger
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1,28 @@
|
|
|
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!
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
|
5
|
+
|
|
6
|
+
# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
|
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format
|
|
4
|
+
# (all these examples are active by default):
|
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
8
|
+
# inflect.irregular 'person', 'people'
|
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
|
10
|
+
# end
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
|
15
|
+
ActiveSupport.use_standard_json_time_format = true
|
|
16
|
+
|
|
17
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
|
18
|
+
# if you're including raw json in an HTML page.
|
|
19
|
+
ActiveSupport.escape_html_entities_in_json = false
|
|
@@ -0,0 +1,15 @@
|
|
|
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 => '_sample_rails_app_session',
|
|
9
|
+
:secret => '7cb2a88554d76daa608888a39f33a161bea2251cdac44907a7acde391458b7d716facafddba6b1f671fb396af337a772084e4ab2c49a39edc86f2c12e361708d'
|
|
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
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
|
2
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
|
3
|
+
# then regenerate this schema definition.
|
|
4
|
+
#
|
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
9
|
+
#
|
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
|
11
|
+
|
|
12
|
+
ActiveRecord::Schema.define(:version => 20090319115628) do
|
|
13
|
+
|
|
14
|
+
create_table "bottles", :force => true do |t|
|
|
15
|
+
t.string "type"
|
|
16
|
+
t.string "name"
|
|
17
|
+
t.integer "universe_id"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Logfile created on Mon Aug 24 22:38:17 +0530 2009
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
|
+
|
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
|
8
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
9
|
+
<style type="text/css">
|
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
11
|
+
div.dialog {
|
|
12
|
+
width: 25em;
|
|
13
|
+
padding: 0 4em;
|
|
14
|
+
margin: 4em auto 0 auto;
|
|
15
|
+
border: 1px solid #ccc;
|
|
16
|
+
border-right-color: #999;
|
|
17
|
+
border-bottom-color: #999;
|
|
18
|
+
}
|
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
<!-- This file lives in public/404.html -->
|
|
25
|
+
<div class="dialog">
|
|
26
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
27
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
28
|
+
</div>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|